cache 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cache.rb +3 -3
- data/lib/cache/version.rb +1 -1
- data/test/shared_tests.rb +14 -1
- metadata +3 -3
data/lib/cache.rb
CHANGED
@@ -157,11 +157,11 @@ class Cache
|
|
157
157
|
def extract_ttl(ttl)
|
158
158
|
case ttl
|
159
159
|
when ::Hash
|
160
|
-
ttl[:expires_in]
|
160
|
+
ttl[:expires_in] || ttl['expires_in'] || ttl[:ttl] || ttl['ttl'] || config.default_ttl
|
161
161
|
when ::NilClass
|
162
162
|
config.default_ttl
|
163
163
|
else
|
164
|
-
ttl
|
165
|
-
end
|
164
|
+
ttl
|
165
|
+
end.to_i
|
166
166
|
end
|
167
167
|
end
|
data/lib/cache/version.rb
CHANGED
data/test/shared_tests.rb
CHANGED
@@ -74,6 +74,14 @@ module SharedTests
|
|
74
74
|
assert_equal 'world', @cache.fetch('hello', :expires_in => 5) { 'world' }
|
75
75
|
end
|
76
76
|
|
77
|
+
def test_fetch_with_expires_in_stringified
|
78
|
+
assert_equal 'world', @cache.fetch('hello', 'expires_in' => 5) { 'world' }
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_fetch_with_ignored_options
|
82
|
+
assert_equal 'world', @cache.fetch('hello', :foo => 'bar') { 'world' }
|
83
|
+
end
|
84
|
+
|
77
85
|
def test_cas
|
78
86
|
toggle = lambda do |current|
|
79
87
|
current == 'on' ? 'off' : 'on'
|
@@ -100,7 +108,12 @@ module SharedTests
|
|
100
108
|
sleep 2
|
101
109
|
assert_equal nil, @cache.get('hello')
|
102
110
|
end
|
103
|
-
|
111
|
+
|
112
|
+
def test_write_with_ignored_options
|
113
|
+
@cache.write 'hello', 'world', :foobar => 'bazboo'
|
114
|
+
assert_equal 'world', @cache.get('hello')
|
115
|
+
end
|
116
|
+
|
104
117
|
def test_read
|
105
118
|
@cache.set 'hello', 'world'
|
106
119
|
assert_equal 'world', @cache.read('hello')
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 2
|
10
|
+
version: 0.2.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Seamus Abshere
|