zache 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e1946835650fe9364a00701710789c08de9e93b03b1885a9ac924203940c2b27
4
- data.tar.gz: 99cb4f482d86a3c1288ef8705c05638a24fd7e580d682e60fa610e61a0e92f02
3
+ metadata.gz: dbc07440cf1bc314b4a2d64f2dbd2f96509fa241f4e9e6e4f3dd5a32a0ec7adf
4
+ data.tar.gz: 4cb895d3b70c72bc03366207adb245b7ca38773626e71cc118e8aae412d1b349
5
5
  SHA512:
6
- metadata.gz: 93ea85258dd3439d79ebfff81676e8a60dffcfba29539d5fa1a180682001e92cb0cc4841274f985cbce164bc10b4767654e64a4edc4db76c43b68bf5b1017a62
7
- data.tar.gz: eb1084cc733ca67a49783526621c81289e0492e3de9d1483ecaa557763588aa2d29414ab570b23f25865e41b62f80b039ee414d75b3d8d76608f0f097cb5387c
6
+ metadata.gz: f76c45b4f213d7df68cdb261eb4ba748191a6bd61e80b90ea438c1a353b7e648efa79175662afc8ce6081b60759b617884f6dbc97d40c84decdeeb16ad17a31e
7
+ data.tar.gz: e1c6a58bd8ac9d63e7da8abfcdc6fd7f729b90da5115b14006268360afa7857618af1003ef286b154529580808be75915e7b44d9e2bae1104133fd9759151a22
@@ -41,6 +41,10 @@ class Zache
41
41
  # does. It implements all methods of the original class, but doesn't do
42
42
  # any caching. This is very useful for testing.
43
43
  class Fake
44
+ def size
45
+ 1
46
+ end
47
+
44
48
  def get(*)
45
49
  yield
46
50
  end
@@ -76,6 +80,11 @@ class Zache
76
80
  @mutex = Mutex.new
77
81
  end
78
82
 
83
+ # Total number of keys currently in cache.
84
+ def size
85
+ @hash.size
86
+ end
87
+
79
88
  # Gets the value from the cache by the provided key. If the value is not
80
89
  # found in the cache, it will be calculated via the provided block. If
81
90
  # the block is not given, an exception will be raised. The lifetime
@@ -40,6 +40,7 @@ class ZacheTest < Minitest::Test
40
40
  first = cache.get(:hey, lifetime: 5) { Random.rand }
41
41
  second = cache.get(:hey) { Random.rand }
42
42
  assert(first == second)
43
+ assert_equal(1, cache.size)
43
44
  end
44
45
 
45
46
  def test_caches_and_expires
@@ -31,7 +31,7 @@ Gem::Specification.new do |s|
31
31
  s.rubygems_version = '2.5'
32
32
  s.required_ruby_version = '>=2.5'
33
33
  s.name = 'zache'
34
- s.version = '0.6.0'
34
+ s.version = '0.7.0'
35
35
  s.license = 'MIT'
36
36
  s.summary = 'In-memory Cache'
37
37
  s.description = 'Zero-footprint in-memory thread-safe cache'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko