sideroo 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5553a7ee34ceb7c54c39d8d9d3fcf409515745f06a951a077fa3dade1ea8227b
4
- data.tar.gz: 1bc91fa63750c7a9f97b904059bc94eecaea61ebaea85760d05483480baaea7e
3
+ metadata.gz: 03a7b294f185dedea2a5a2b24280df69d4102e54bdaf729819b4823205e7057c
4
+ data.tar.gz: 654bca601be4cc8481d5be43410b96f3bf7029b3212828d89d183b593d9acd7d
5
5
  SHA512:
6
- metadata.gz: d1054a3f260db3e4cfefe54e55b365e447ba6c90263f1ab68c6a8408c2bed63c64caf6a5dc54a4550e7c41425fc397a0f3d1c54c88bf20316d381490e0637f46
7
- data.tar.gz: acad185b19f07e88a74af249bf845f6564f750d2d56896f78b00a2f39090f573244697395ad98bc86f9c1f90f269efc8b9da918ad177be36ebf9275fa38eef0c
6
+ metadata.gz: 19dafd77261755bfc811c4520f299b5b895ac4daaf2c4016e5d0172f794369c9a5574b397aa294dcf8420bea03fed7e6ee9f0b797a40828accb896fb52a6566c
7
+ data.tar.gz: 592e26ba47f3e4547b7e57a4353c4d13b44158d1904fe09635d178b94f7ea41c200747e5d42faa1a3ea8dc0a95b2b92bd2a1adb4d2418d8355188b118a59afe1
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sideroo (1.0.0)
4
+ sideroo (1.1.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -30,9 +30,9 @@ This gem is aimed to provide
30
30
  ```
31
31
  - an **auditable** Redis key management
32
32
  ```rb
33
- TopStoriesCache.count # key count - COMING SOON
33
+ TopStoriesCache.count # key count
34
34
  TopStoriesCache.all.map(&:key) # list all keys
35
- TopStoriesCache.flush # delete all keys of the same pattern - COMING SOON
35
+ TopStoriesCache.flush # delete all keys of the same pattern
36
36
 
37
37
  # Support `where` for key searching
38
38
  # `each`, `map` for enumerable
@@ -257,7 +257,7 @@ TopStoriesCache.count # Scan and count
257
257
  TopStoriesCache.all.to_a # NOT RECOMMENDED if there are too many keys
258
258
  ```
259
259
 
260
- ### 3.6. Flush keys - COMING SOON
260
+ ### 3.6. Flush keys
261
261
 
262
262
  ```rb
263
263
  TopStoriesCache.flush # Delete all keys of TopStoriesCache
@@ -20,6 +20,16 @@ module Sideroo
20
20
  cursor = nil
21
21
  count = 0
22
22
 
23
+ each_key do |key|
24
+ item = type_klass.new(key)
25
+ yield(item)
26
+ end
27
+ end
28
+
29
+ def each_key
30
+ cursor = nil
31
+ count = 0
32
+
23
33
  until cursor.to_s == '0'
24
34
  cursor ||= 0
25
35
  cursor, keys = redis_client.scan(cursor, match: search_pattern)
@@ -29,8 +39,7 @@ module Sideroo
29
39
  next unless regex_matched?(key)
30
40
 
31
41
  count += 1
32
- item = type_klass.new(key)
33
- yield(item)
42
+ yield(key)
34
43
  end
35
44
  end
36
45
  end
@@ -45,7 +54,7 @@ module Sideroo
45
54
 
46
55
  def count
47
56
  count = 0
48
- each { count += 1 }
57
+ each_key { count += 1 }
49
58
  count
50
59
  end
51
60
 
@@ -58,6 +58,14 @@ module Sideroo
58
58
  where({})
59
59
  end
60
60
 
61
+ def count
62
+ all.count
63
+ end
64
+
65
+ def flush
66
+ all.each(&:del)
67
+ end
68
+
61
69
  def example_valid?
62
70
  example.nil? || example =~ key_regex
63
71
  end
@@ -1,3 +1,3 @@
1
1
  module Sideroo
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sideroo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Duong Nguyen