1 ! Copyright (C) 2014 Benjamin Pollack
2 ! See http://factorcode.org/license.txt for BSD license
4 USING: continuations kernel redis math math.parser sequences
11 : with-redis ( quot -- )
12 [ redis-flushdb ] prepose
13 <redis> swap redis:with-redis ; inline
15 { -1 } [ [ "foo" redis-decr ] with-redis ] unit-test
17 { 1 } [ [ "foo" redis-incr ] with-redis ] unit-test
20 [ 2 "foo" redis-decrby ] with-redis
23 { 2 } [ [ 2 "foo" redis-incrby ] with-redis ] unit-test
27 "hello" "foo" redis-set
32 { { "aa" "ab" "ac" } } [
34 { "aa" "ab" "ac" "bd" } [ "hello" swap redis-set ] each
35 "a*" redis-keys natural-sort
41 "world" "hello" redis-set redis-randomkey
45 { { "3" "2" "1" } "1" "5" "3" } [
48 number>string "list" redis-lpush drop
50 0 -1 "list" redis-lrange
51 "5" 1 "list" redis-lset
52 3 [ "list" redis-rpop ] times
56 { { "world" } "1" 2 } [
58 "1" "world" "hello" redis-hset drop
60 "world" "hello" redis-hget
61 1 "world" "hello" redis-hincrby
67 "world" "hello" redis-set
68 [ "hello" redis-incr ] [ drop t ] recover