[Announce] Shell variables bound to redis db (via hiredis)

11 views
Skip to first unread message

Sebastian Gniazdowski

unread,
Jun 1, 2017, 4:34:22 AM6/1/17
to redi...@googlegroups.com
Hello,
I've written Zsh module that uses hiredis to map redis keys to shell variables. All types are supported. Maybe the module deserves some recognition?

The point is that this is miles away from redis-cli usage. For example, to copy one hash to another:

% zrtie -r -d db/redis -f "127.0.0.1/3/HASHSET1" hset1 # -r - read-only
% zrtie -d db/redis -f "127.0.0.1/3/HASHSET2" hset2
% hset2=( "${(kv)hset1[@]}" )

To generate multiple keys for sorted set:

% zrtie -d db/redis -f "127.0.0.1/3/NEWZSET" zset
% count=0
% for i in {a..z} {A..Z}; do
> (( count ++ ))
> zset[$i]=$count;
> done

Doing such things with redis-cli is hard. To remove part of list (or set):

% redis-cli -n 4 rpush LIST value1 value2 value3 value4
% zrtie -d db/redis -f "127.0.0.1/4/LIST" mylist
% mylist[2,-1]=()
% redis-cli -n 4 lrange LIST 0 -1
1) "value1"

The module is a Zsh plugin, only sourcing it is needed, it will automatically detect hiredis library, build and load. Home page: https://github.com/zdharma/zredis

--
Sebastian Gniazdowski
psprint /at/ zdharma.org
Reply all
Reply to author
Forward
0 new messages