Categories:
aura-mocks-redis-service plugin
Module that connect plugins to Redis database
Description
aura-mocks-redis-service plugin is a tool using aura-redis-handler that allows the connection of plugins to Redis database.
Find more information in the Github repository:
https://github.com/Telefonica/aura-mocks-server/tree/master/src/plugins/aura-mocks-redis-service
This is part of aura-mocks-server project.
Methods
delete
Delete element by key from Redis.
| Property | Type | Description |
|---|---|---|
| pattern | string | Unique key for Redis |
| corr | string | Unique correlator |
Example:
await redisService.delete('test-key', 'test-correlator');
get
Get element by key from Redis.
| Property | Type | Description |
|---|---|---|
| pattern | string | Unique key for Redis |
| corr | string | Unique correlator |
Example:
await redisService.get('test-key', 'test-correlator');
info
Return info from Redis.
| Property | Type | Description |
|---|---|---|
| sections | string[]/undefined | Array with sections |
| corr | string | Unique correlator |
Example:
await redisService.info(['section_1'], 'test-correlator');
lPush
Put an element at the beginning of a Redis list.
| Property | Type | Description |
|---|---|---|
| pattern | string | Unique key for Redis |
| value | string | Data to save |
| corr | string | Unique correlator |
Example:
await redisService.lPush('test-key', 'data', 'test-correlator');
rPush
Put an element at the end of a Redis list.
| Property | Type | Description |
|---|---|---|
| pattern | string | Unique key for Redis |
| value | string | Data to save |
| corr | string | Unique correlator |
Example:
await redisService.rPush('test-key', 'data', 'test-correlator');
lRange
Get elements by key and range from Redis list.
| Property | Type | Description |
|---|---|---|
| pattern | string | Unique key for Redis |
| from | number | Start index |
| to | number | End index |
| corr | string | Unique correlator |
Example:
await redisService.lRange('test-key', 0, 10, 'test-correlator');
set
Add data by key to Redis.
| Property | Type | Description |
|---|---|---|
| pattern | string | Unique key for Redis |
| value | string | Data to save |
| corr | string | Unique correlator |
Example:
await redisService.set('test-key', 'data', 'test-correlator');
sAdd
Add element to the set of Redis.
| Property | Type | Description |
|---|---|---|
| pattern | string | Unique key for Redis |
| value | string | Data to save |
| corr | string | Unique correlator |
Example:
await redisService.sAdd('test-key', 'data', 'test-correlator');
sInter
Get elements by key Redis.
| Property | Type | Description |
|---|---|---|
| pattern | string | Unique key for Redis |
| corr | string | Unique correlator |
Example:
await redisService.sInter('test-key', 'data', 'test-correlator');
sRem
Remove element from the set of Redis.
| Property | Type | Description |
|---|---|---|
| pattern | string | Unique key for Redis |
| value | string | Value to search |
| corr | string | Unique correlator |
Example:
await redisService.sRem('test-key', 'data', 'test-correlator');
zAdd
Add element to the sorted set.
| Property | Type | Description |
|---|---|---|
| pattern | string | Unique key for Redis |
| score | number | Index of the element |
| value | string | Value to add |
| corr | string | Unique correlator |
Example:
await redisService.zAdd('test-key', 'data', 'test-correlator');
zRevRange
Get elements by key and range.
| Property | Type | Description |
|---|---|---|
| pattern | string | Unique key for Redis |
| from | string/number | Start index |
| to | string/number | End index |
| corr | string | Unique correlator |
Example:
await redisService.zRevRange('test-key', 0, 10, 'test-correlator');
withLock
Lock Redis key and execute function.
| Property | Type | Description |
|---|---|---|
| fn | function | Callback |
| key | string | Key to lock |
| corr | string | Unique correlator |
Example:
await redisService.withLock(await () => true, 'test-key', 'test-correlator');