1 | # yas-redis
|
2 | A Redis client
|
3 |
|
4 | > It's an extension for `yaml-scene`
|
5 |
|
6 | ## Features:
|
7 | - Redis live query tool
|
8 | - Execute redis command in scenario
|
9 |
|
10 | > Easy to create step by step for migration
|
11 | > Easy to connect to many servers
|
12 |
|
13 | ## Sharing
|
14 | 1. [Redis live query tool](./sharing/README.md)
|
15 |
|
16 | ## Details document
|
17 | > [Wiki Pages](./GUIDE.md)
|
18 |
|
19 | ## Prerequisite
|
20 | - Platform [`yaml-scene`](https://www.npmjs.com/package/yaml-scene)
|
21 |
|
22 | ## Installation
|
23 |
|
24 | ```sh
|
25 | yas add yas-redis # npm install -g yas-redis OR yard global add yas-redis
|
26 | ```
|
27 |
|
28 | ## Example
|
29 | [Examples scenario files](./scenes/test)
|
30 |
|
31 | ## Redis executor
|
32 | Execute redis command in scenario
|
33 |
|
34 | ```yaml
|
35 | - yas-redis:
|
36 | title: Redis in localhost
|
37 | uri: # redis://user:pass@ip:port/db
|
38 | commands: # Redis command
|
39 | - set name "thanh 01" # - Set "thanh 01" to key "name"
|
40 | - set age 10 # - Set "10" to key "age"
|
41 |
|
42 | - flushdb # - flushdb, flushall
|
43 |
|
44 | - cmd: # Command with args for object
|
45 | - hmset
|
46 | - post
|
47 | - name: 10
|
48 | age: 11
|
49 |
|
50 | - title: Cached post data # Command title
|
51 | cmd: hset post 10 '{"name":10}' # Redis co
|
52 |
|
53 | - title: Get post data in cached # Command title
|
54 | cmd: hget post 10 # Redis command
|
55 | var: post # Set result to "post" var
|
56 |
|
57 | - cmd: !function # Write code in command
|
58 | () { # Declare variable is used. Redis is [ioredis](https://github.com/luin/ioredis)
|
59 | await this.redis.set('name', thanh) # Need "await" when use redis functions then return value to apply to variable
|
60 | const rs = await this.redis.get('name')
|
61 | return rs
|
62 | }
|
63 | var: nameValue
|
64 | ```
|
65 |
|
66 | # Live redis executor
|
67 |
|
68 | ```yaml
|
69 | - yas-redis/Live:
|
70 | uri: # redis://user:pass@ip:port/db
|
71 | opts: # Redis options (ioredis).
|
72 | # - Reference to https://github.com/luin/ioredis/blob/df04dd8/lib/redis/RedisOptions.ts#L184
|
73 | pretty: false # Pretty format data
|
74 | limit: 3 # Num of line show in history
|
75 | history: true # Reset history or not
|
76 | # - true: Store commands histories
|
77 | # - false: Dont store commands histories
|
78 | # - "clean": Clean old histories before store again
|
79 | ``` |
\ | No newline at end of file |