21
21
- [ Redis list -> Zsh array] ( #redis-list---zsh-array )
22
22
- [ Redis string key -> Zsh string] ( #redis-string-key---zsh-string )
23
23
- [ Installation] ( #installation )
24
- - [ Zinit] ( #zinit )
25
- - [ Antigen] ( #antigen )
26
- - [ Oh-My-Zsh] ( #oh-my-zsh )
27
- - [ Zgen] ( #zgen )
24
+ - [ Zinit] ( #zinit )
25
+ - [ Antigen] ( #antigen )
26
+ - [ Oh-My-Zsh] ( #oh-my-zsh )
27
+ - [ Zgen] ( #zgen )
28
28
- [ Zredis Zstyles] ( #zredis-zstyles )
29
29
30
30
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
31
31
32
- # Introduction
32
+ ## Introduction
33
33
34
34
Zsh binary module written in C interfacing with ` redis ` database via ` Zshell `
35
35
` variables ` mapped to ` keys ` or the whole ` database ` .
@@ -62,7 +62,7 @@ key1 key2
62
62
2) "key2"
63
63
```
64
64
65
- ## Rationale
65
+ ### Rationale
66
66
67
67
Building commands for ` redis-cli ` quickly becomes inadequate. For example, if copying
68
68
of one hash to another one is needed, what ` redis-cli ` invocations are needed? With
@@ -103,7 +103,7 @@ Output: $reply array, to hold elements of the sorted set
103
103
a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
104
104
```
105
105
106
- ## Deleting From Database
106
+ ### Deleting From Database
107
107
108
108
Unsetting the first type of mapped variable (Zsh hash -> whole database) doesn't cause a deletion from
109
109
database. If option ` -D ` is given to ` ztie ` when binding to concrete key in database, then unsets, also
@@ -114,15 +114,15 @@ More: in Redis, removing all elements from a set, list, etc. means the same as d
114
114
all datatypes except string, by doing ` variable=() ` . For string you can unset key in whole-database mapped
115
115
hash: ` unset 'wholedb[key]' ` .
116
116
117
- ## Compiling modules
117
+ ### Compiling modules
118
118
119
119
The Zsh modules provided by the plugin will build automatically (` hiredis ` library is needed). You can
120
120
start more than 1 shell, only the first one will be compiling. If a developer commits a new timestamp to
121
121
` module/RECOMPILE_REQUEST ` , the module will recompile (don't worry, at startup, ` mtime ` is checked
122
122
first, so check for recompilation is fast). I do this when I add tested features or fixes. You can
123
123
recompile the modules yourself by invoking Zsh function ` zredis_compile ` .
124
124
125
- ## Cache
125
+ ### Cache
126
126
127
127
By default, reads are cached. If a tied variable is read for the first time,
128
128
then database is accessed. For the second read there's no database access.
@@ -137,7 +137,7 @@ ztclear my_hashset_var key # Also for types: whole-db mapping, zset
137
137
138
138
To disable the cache, pass ` -z ` ("zero-cache") option to ztie.
139
139
140
- ## News
140
+ ### News
141
141
142
142
- 2018-12-19
143
143
- The builtin ` zrpush ` can have the param-name argument skipped – if it's called for the second
@@ -159,9 +159,9 @@ To disable the cache, pass `-z` ("zero-cache") option to ztie.
159
159
- New option to ` ztie ` : ` -D ` , which causes mapped database key to be deleted on ` unset ` of the tied
160
160
variable. Up to this moment this behavior was the default.
161
161
162
- ## Mapping Of Redis Types To Zsh Data Structures
162
+ ### Mapping Of Redis Types To Zsh Data Structures
163
163
164
- ### Database string keys -> Zsh hash
164
+ #### Database string keys -> Zsh hash
165
165
166
166
Redis can store strings at given keys, using ` SET ` command. ` Zredis ` maps those to hash array
167
167
(like Zsh ` gdbm ` module):
@@ -176,7 +176,7 @@ redis
176
176
key1 value1 key2 value2
177
177
```
178
178
179
- ### Redis hash -> Zsh hash
179
+ #### Redis hash -> Zsh hash
180
180
181
181
By appending ` /NAME ` to the ` host-spec ` (` -f ` option), one can select single
182
182
key of type ` HASH ` and map it to ` Zsh ` hash:
@@ -195,7 +195,7 @@ value2
195
195
key1 value1
196
196
```
197
197
198
- ### Redis set -> Zsh array
198
+ #### Redis set -> Zsh array
199
199
200
200
Can clear single elements by assigning ` () ` to array element. Can overwrite
201
201
whole set by assigning via ` =( ... ) ` to set, and delete set from database
@@ -219,7 +219,7 @@ value2 value3 value1
219
219
(empty list or set)
220
220
```
221
221
222
- ### Redis sorted set -> Zsh hash
222
+ #### Redis sorted set -> Zsh hash
223
223
224
224
This variant maps ` zset ` as hash - keys are set elements, values are ranks.
225
225
` zrzset ` call outputs elements sorted according to the rank:
236
236
b a
237
237
```
238
238
239
- ### Redis list -> Zsh array
239
+ #### Redis list -> Zsh array
240
240
241
241
There is no analogue of ` zrzset ` call because ` Zsh ` array already has correct order:
242
242
@@ -256,7 +256,7 @@ value1 value2 value3
256
256
3) " 3"
257
257
```
258
258
259
- ### Redis string key -> Zsh string
259
+ #### Redis string key -> Zsh string
260
260
261
261
Single keys in main Redis storage are bound to ` Zsh ` string variables:
262
262
@@ -278,7 +278,7 @@ value2
278
278
" value2"
279
279
```
280
280
281
- # Installation
281
+ ## Installation
282
282
283
283
** The plugin is "standalone"** , which means that only sourcing it is needed. So to
284
284
install, unpack ` zredis ` somewhere and add
@@ -315,7 +315,7 @@ cloning the plugin for you automatically the next time you start zsh.
315
315
Add ` zgen load z-shell/zredis ` to your .zshrc file in the same place you're doing
316
316
your other ` zgen load ` calls in.
317
317
318
- # Zredis Zstyles
318
+ ## Zredis Zstyles
319
319
320
320
The values being set are the defaults. Change the values before loading ` zredis ` plugin.
321
321
0 commit comments