Skip to content

Commit

Permalink
Merge pull request #10 from heliumtank92/v2.0.x
Browse files Browse the repository at this point in the history
V2.0.x
  • Loading branch information
heliumtank92 authored Nov 16, 2023
2 parents 6b2509a + 5a3a4e5 commit 676e71e
Show file tree
Hide file tree
Showing 112 changed files with 17,428 additions and 1,500 deletions.
17 changes: 17 additions & 0 deletions .compodocrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"include": ["src/**/*.ts"],
"exclude": ["src/test.ts", "src/**/*.spec.ts", "src/app/file-to-exclude.ts"],
"output": "docs",
"name": "RedisSdk",
"silent": true,
"hideGenerator": true,
"disableSourceCode": true,
"disableInternal": true,
"navTabConfig": [
{
"id": "info",
"label": "Documentation"
}
],
"theme": "gitbook"
}
14 changes: 14 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"globals": {
"React": true,
"google": true,
"mount": true,
"mountWithRouter": true,
"shallow": true,
"shallowWithRouter": true,
"context": true,
"expect": true,
"jsdom": true,
"JSX": true
}
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ node_modules/
# Generated by Windows
Thumbs.db

# Build
dist/

# Tests
coverage/
profile/
Expand Down
8 changes: 8 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,11 @@ coverage/
profile/
reports/
tests/

# Source
src/
tsconfig.json

# Documentation
docs/
.compodocrc.json
220 changes: 8 additions & 212 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ This package provides the following functionalities:
- [Installation](#installation)
- [Environment Variables](#environment-variables)
- [Creating a Redis SDK Instance](#creating-a-redis-sdk-instance)
- [Properties of RedisSdk Instance](#properties-of-redissdk-instance)
- [Methods of RedisSdk Instance](#methods-of-redissdk-instance)
- [Contributors](#contributors)
- [Resources](#resources)
- [License](#license)
Expand Down Expand Up @@ -70,8 +68,11 @@ import RedisSdk from '@am92/redis'

const config = {
CONNECTION_CONFIG: {
host: '',
port: '',
socket: {
host: '',
port: 6379,
tls: true
},
password: ''
}
KEY_PREFIX: ''
Expand All @@ -81,222 +82,17 @@ const redisSdk = new RedisSdk(config)
export default redisSdk
```

To manage redis connections for RedisSdk Instances with custom 'config', 'connect' and 'disconnect' Methods are provided and they can be called as shown below. The 'connect' method must be called before before using the RedisSdk Methods.
To manage redis connections for RedisSdk Instances, 'connect' and 'disconnect' methods are provided and they can be called as shown below. The 'connect' method must be called before before using the RedisSdk Methods.

```javascript
// To establish a connection
await redisSdk.connect()

// To release the connection
await redisSdk.disconnect()
```

<br />

### Properties of RedisSdk Instance
| Properties | Description |
| :------------------------- | :-------------------------------- |
| redisSdk.CONNECTION_CONFIG | Connection Config used by the SDK |
| redisSdk.KEY_PREFIX | Redis Key Prefix used by the SDK |

<br />

### Methods of RedisSdk Instance
| Method | Description |
| :------------------------------------------------------------------------ | :------------------------------------------------------ |
| [redisSdk.get](#redissdkgetkey-options) | Gets the value of a redis key |
| [redisSdk.set](#redissdksetkey-value-options) | Sets the value for a redis key |
| [redisSdk.getAndExpire](#redissdkgetandexpirekey-ttlinsecs-options) | Gets the value of a redis key and sets its expiry |
| [redisSdk.setAndExpire](#redissdksetandexpirekey-value-ttlinsecs-options) | Sets the value of a redis key and sets its expiry |
| [redisSdk.del](#redissdkdelkey) | Deletes a redis key |
| [redisSdk.keys](#redissdkkeyspattern) | Gets all redis keys for a given key pattern |
| [redisSdk.delByPattern](#redissdkdelbypatternpattern) | Deletes all redis keys for a given key pattern |
| [redisSdk.incrBy](#redissdkincrbykey-value) | Increments the value of a redis key |
| [redisSdk.incrByAndExpire](#redissdkincrbyandexpirekey-value-ttlinsecs) | Increments the value of a redis key and sets its expiry |
| [redisSdk.decrBy](#redissdkdecrbykey-value) | Decrements the value of a redis key |
| [redisSdk.decrByAndExpire](#redissdkdecrbyandexpirekey-value-ttlinsecs) | Decrements the value of a redis key and sets its expiry |
| [redisSdk.exists](#redissdkexistskeys) | Returns if keys exists or not |

<br />

#### redisSdk.get(key, options)<br />
###### Arguments
* key (String): Redis key name
* options (Object): options as mentioned by 'get' method of redis package

###### Returns
* value (any): Value stored in redis

###### Example
```javascript
const value = await redisSdk.get(key, options)
```

<br />

#### redisSdk.set(key, value, options)<br />
###### Arguments
* key (String): Redis key name
* value (any): Value to be stored in redis
* options (Object): options as mentioned by 'set' method of redis package

###### Returns
* undefined

###### Example
```javascript
await redisSdk.set(key, value, options)
```

<br />

#### redisSdk.getAndExpire(key, ttlInSecs, options)<br />
###### Arguments
* key (String): Redis key name
* ttlInSecs (Number): Redis key expiry in seconds
* options (Object): options as mentioned by 'get' method of redis package

###### Returns
* value (any): Value stored in redis

###### Example
```javascript
const value = await redisSdk.getAndExpire(key, ttlInSecs, options)
```

<br />

#### redisSdk.setAndExpire(key, value, ttlInSecs, options)<br />
###### Arguments
* key (String): Redis key name
* value (any): Value to be stored in redis
* ttlInSecs (Number): Redis key expiry in seconds
* options (Object): options as mentioned by 'set' method of redis package

###### Returns
* undefined

###### Example
```javascript
await redisSdk.setAndExpire(key, value, ttlInSecs, options)
```

<br />

#### redisSdk.del(key)<br />
###### Arguments
* key (String): Redis key name

###### Returns
* undefined

###### Example
```javascript
await redisSdk.del(key)
```

<br />

#### redisSdk.keys(pattern)<br />
###### Arguments
* pattern (String): Redis key pattern

###### Returns
* keys (Array): Array of keys

###### Example
```javascript
const keys = await redisSdk.keys(pattern)
```

<br />

#### redisSdk.delByPattern(pattern)<br />
###### Arguments
* pattern (String): Redis key pattern

###### Returns
* undefined

###### Example
```javascript
await redisSdk.delByPattern(pattern)
```

<br />

#### redisSdk.incrBy(key, value)<br />
###### Arguments
* key (String): Redis key name
* value (Number): Redis value to be incremented by *(Defaults to 0)*

###### Returns
* incrValue (Number): Incremented redis value

###### Example
```javascript
const incrValue = await redisSdk.incrBy(key, value)
```

<br />

#### redisSdk.incrByAndExpire(key, value, ttlInSecs)<br />
###### Arguments
* key (String): Redis key name
* value (Number): Redis value to be incremented by *(Defaults to 0)*
* ttlInSecs (Number): Redis key expiry in seconds

###### Returns
* incrValue (Number): Incremented redis value

###### Example
```javascript
const incrValue = await redisSdk.incrByAndExpire(key, value, ttlInSecs)
```

<br />

#### redisSdk.decrBy(key, value)<br />
###### Arguments
* key (String): Redis key name
* value (Number): Redis value to be decremented by *(Defaults to 0)*

###### Returns
* decrValue (Number): Decremented redis value

###### Example
```javascript
const decrValue = await redisSdk.decrBy(key, value)
```

<br />

#### redisSdk.decrByAndExpire(key, value, ttlInSecs)<br />
###### Arguments
* key (String): Redis key name
* value (Number): Redis value to be decremented by *(Defaults to 0)*
* ttlInSecs (Number): Redis key expiry in seconds

###### Returns
* decrValue (Number): Decremented redis value

###### Example
```javascript
const decrValue = await redisSdk.decrByAndExpire(key, value, ttlInSecs)
```

<br />

#### redisSdk.exists(keys)<br />
###### Arguments
* keys (Array): Array of redis key names

###### Returns
* keyCount (Number): Returns '0' if key does not exist and '1' if exists

###### Example
```javascript
const keyCount = await redisSdk.exists(keys)
// To force release the connection
await redisSdk.disconnect(true)
```

<br />
Expand Down
Loading

0 comments on commit 676e71e

Please sign in to comment.