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
9 : with-redis-test ( quot -- )
10 [ redis-flushdb ] prepose
11 <redis> swap with-redis ; inline
13 { -1 } [ [ "foo" redis-decr ] with-redis-test ] unit-test
15 { 1 } [ [ "foo" redis-incr ] with-redis-test ] unit-test
18 [ 2 "foo" redis-decrby ] with-redis-test
21 { 2 } [ [ 2 "foo" redis-incrby ] with-redis-test ] unit-test
25 "hello" "foo" redis-set
30 { { "aa" "ab" "ac" } } [
32 { "aa" "ab" "ac" "bd" } [ "hello" swap redis-set ] each
33 "a*" redis-keys natural-sort
39 "world" "hello" redis-set redis-randomkey
43 { { "3" "2" "1" } "1" "5" "3" } [
46 number>string "list" redis-lpush drop
48 0 -1 "list" redis-lrange
49 "5" 1 "list" redis-lset
50 3 [ "list" redis-rpop ] times
54 { { "world" } "1" 2 } [
56 "1" "world" "hello" redis-hset drop
58 "world" "hello" redis-hget
59 1 "world" "hello" redis-hincrby
65 "world" "hello" redis-set
66 [ "hello" redis-incr ] [ drop t ] recover