zache 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zache.rb +7 -0
- data/test/test_zache.rb +7 -0
- data/zache.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c2af949ace2c9836128379aac9360bfc0aeff387e700b464f7c300ad3e1fea7
|
4
|
+
data.tar.gz: 4c4b7ddf99e30e27b012e8d98f9b102acff016e4ec6021953008bc8283f8f08f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 842ee794a1d2055bec22948417227b24d56fbe016c8828d16db01e75e61908895ae3ba71620fd5fca0ec1c7f8c28f99407ead492c486a64fa9f0e9478b07429c
|
7
|
+
data.tar.gz: 18a3c7f5af71e1edf227954391eb9265e1a4dd812480931841bf0ac47b6f77387814f749cb8bb3a98280fc724b83af188a5c13d6c16e19ef4cfc3118377dddde
|
data/lib/zache.rb
CHANGED
@@ -123,6 +123,13 @@ class Zache
|
|
123
123
|
!rec.nil?
|
124
124
|
end
|
125
125
|
|
126
|
+
# Returns the modification time of the key, if it exists.
|
127
|
+
# If not, current time is returned.
|
128
|
+
def mtime(key)
|
129
|
+
rec = @hash[key]
|
130
|
+
rec.nil? ? Time.now : rec[:start]
|
131
|
+
end
|
132
|
+
|
126
133
|
# Is cache currently locked doing something?
|
127
134
|
def locked?
|
128
135
|
@mutex.locked?
|
data/test/test_zache.rb
CHANGED
@@ -51,6 +51,13 @@ class ZacheTest < Minitest::Test
|
|
51
51
|
assert(first != second)
|
52
52
|
end
|
53
53
|
|
54
|
+
def test_calculates_age
|
55
|
+
cache = Zache.new
|
56
|
+
cache.get(:hey) { Random.rand }
|
57
|
+
sleep 0.1
|
58
|
+
assert(cache.mtime(:hey) < Time.now - 0.05)
|
59
|
+
end
|
60
|
+
|
54
61
|
def test_caches_in_threads
|
55
62
|
cache = Zache.new
|
56
63
|
Threads.new(10).assert(100) do
|
data/zache.gemspec
CHANGED
@@ -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.
|
34
|
+
s.version = '0.9.0'
|
35
35
|
s.license = 'MIT'
|
36
36
|
s.summary = 'In-memory Cache'
|
37
37
|
s.description = 'Zero-footprint in-memory thread-safe cache'
|