Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Zsh plugin – redis database keys mapper (to Zsh variables)



Hello
I've released a plugin, maybe it fits upstream? It binds redis keys to shell parameters. For example:

% redis-cli -n 3 hmset HASHSET field1 value1 fld2 val2
% zrtie -d db/redis -f "127.0.0.1/3/HASHSET" hset
% echo ${(kv)hset}
field1 value1 fld2 val2


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
% for i in {a..z} {A..Z}; do
> zset[$i]=$count;
> done

To remove list element:

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

All that is needed to compile is `hiredis` C library.

Project page: https://github.com/zdharma/zredis
--
Sebastian Gniazdowski
psprint /at/ zdharma.org



Messages sorted by: Reverse Date, Date, Thread, Author