@@ -48,11 +48,13 @@ There are data structures for counters, enums, flags, lists, unique lists, sets,
4848list = Kredis .list " mylist"
4949list << " hello world!" # => RPUSH mylist "hello world!"
5050[ " hello world!" ] == list.elements # => LRANGE mylist 0, -1
51+ list.clear # => DEL mylist
5152
5253integer_list = Kredis .list " myintegerlist" , typed: :integer , default: [ 1 , 2 , 3 ] # => EXISTS? myintegerlist, RPUSH myintegerlist "1" "2" "3"
5354integer_list.append([ 4 , 5 , 6 ]) # => RPUSH myintegerlist "4" "5" "6"
5455integer_list << 7 # => RPUSH myintegerlist "7"
5556[ 1 , 2 , 3 , 4 , 5 , 6 , 7 ] == integer_list.elements # => LRANGE myintegerlist 0 -1
57+ integer_list.clear # => DEL myintegerlist
5658
5759unique_list = Kredis .unique_list " myuniquelist"
5860unique_list.append(%w[ 2 3 4 ] ) # => LREM myuniquelist 0, "2" + LREM myuniquelist 0, "3" + LREM myuniquelist 0, "4" + RPUSH myuniquelist "2", "3", "4"
@@ -61,6 +63,7 @@ unique_list.append([])
6163unique_list << " 5" # => LREM myuniquelist 0, "5" + RPUSH myuniquelist "5"
6264unique_list.remove(3 ) # => LREM myuniquelist 0, "3"
6365[ " 4" , " 2" , " 1" , " 5" ] == unique_list.elements # => LRANGE myuniquelist 0, -1
66+ unique_list.clear # => DEL myuniquelist
6467
6568ordered_set = Kredis .ordered_set " myorderedset"
6669ordered_set.append(%w[ 2 3 4 ] ) # => ZADD myorderedset 1646131025.4953232 2 1646131025.495326 3 1646131025.4953272 4
@@ -75,6 +78,7 @@ set.add(DateTime.tomorrow, DateTime.yesterday) # => SADD myset "2021-0
7578set << DateTime .tomorrow # => SADD myset "2021-02-03 00:00:00 +0100"
76792 == set.size # => SCARD myset
7780[ DateTime .tomorrow, DateTime .yesterday ] == set.members # => SMEMBERS myset
81+ set.clear # => DEL myset
7882
7983hash = Kredis .hash " myhash"
8084hash.update(" key" => " value" , " key2" => " value2" ) # => HSET myhash "key", "value", "key2", "value2"
@@ -102,6 +106,7 @@ counter.increment by: 2 # => SET mycounter 0 EX 5 NX + INCRBY "mycounter
1021062 == counter.value # => GET "mycounter"
103107sleep 6 .seconds
1041080 == counter.value # => GET "mycounter"
109+ counter.reset # => DEL mycounter
105110
106111cycle = Kredis .cycle " mycycle" , values: %i[ one two three ]
107112:one == cycle.value # => GET mycycle
@@ -111,6 +116,7 @@ cycle.next # => GET mycycle + SET mycycle 2
111116:three == cycle.value # => GET mycycle
112117cycle.next # => GET mycycle + SET mycycle 0
113118:one == cycle.value # => GET mycycle
119+ cycle.reset # => DEL mycycle
114120
115121enum = Kredis .enum " myenum" , values: %w[ one two three ] , default: " one"
116122" one" == enum.value # => GET myenum
0 commit comments