Skip to content

Commit 31c8eef

Browse files
authored
Update REAME - Add 'clear' method for 'unique_list' (#144)
1 parent 41b5358 commit 31c8eef

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ There are data structures for counters, enums, flags, lists, unique lists, sets,
4848
list = Kredis.list "mylist"
4949
list << "hello world!" # => RPUSH mylist "hello world!"
5050
[ "hello world!" ] == list.elements # => LRANGE mylist 0, -1
51+
list.clear # => DEL mylist
5152

5253
integer_list = Kredis.list "myintegerlist", typed: :integer, default: [ 1, 2, 3 ] # => EXISTS? myintegerlist, RPUSH myintegerlist "1" "2" "3"
5354
integer_list.append([ 4, 5, 6 ]) # => RPUSH myintegerlist "4" "5" "6"
5455
integer_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

5759
unique_list = Kredis.unique_list "myuniquelist"
5860
unique_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([])
6163
unique_list << "5" # => LREM myuniquelist 0, "5" + RPUSH myuniquelist "5"
6264
unique_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

6568
ordered_set = Kredis.ordered_set "myorderedset"
6669
ordered_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
7578
set << DateTime.tomorrow # => SADD myset "2021-02-03 00:00:00 +0100"
7679
2 == set.size # => SCARD myset
7780
[ DateTime.tomorrow, DateTime.yesterday ] == set.members # => SMEMBERS myset
81+
set.clear # => DEL myset
7882

7983
hash = Kredis.hash "myhash"
8084
hash.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
102106
2 == counter.value # => GET "mycounter"
103107
sleep 6.seconds
104108
0 == counter.value # => GET "mycounter"
109+
counter.reset # => DEL mycounter
105110

106111
cycle = 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
112117
cycle.next # => GET mycycle + SET mycycle 0
113118
:one == cycle.value # => GET mycycle
119+
cycle.reset # => DEL mycycle
114120

115121
enum = Kredis.enum "myenum", values: %w[ one two three ], default: "one"
116122
"one" == enum.value # => GET myenum

0 commit comments

Comments
 (0)