mcmire-cache 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
data/lib/cache/version.rb
CHANGED
@@ -0,0 +1,149 @@
|
|
1
|
+
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
require 'active_support/cache'
|
5
|
+
|
6
|
+
class TestActiveSupportCacheNullStore < TestCase
|
7
|
+
def raw_client_class
|
8
|
+
ActiveSupport::Cache::NullStore
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_get
|
12
|
+
assert_equal nil, cache.get('hello')
|
13
|
+
cache.set 'hello', 'world'
|
14
|
+
assert_equal nil, cache.get('hello')
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_set
|
18
|
+
assert_nothing_raised do
|
19
|
+
cache.set 'hello', 'world'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_set_with_ttl
|
24
|
+
cache.set 'hello', 'world', 1
|
25
|
+
assert_equal nil, cache.get('hello')
|
26
|
+
sleep 2
|
27
|
+
assert_equal nil, cache.get('hello')
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_set_with_zero_ttl_meaning_eternal
|
31
|
+
cache.set 'hello', 'world', 0
|
32
|
+
assert_equal nil, cache.get('hello')
|
33
|
+
sleep 1
|
34
|
+
assert_equal nil, cache.get('hello')
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_delete
|
38
|
+
cache.set 'hello', 'world'
|
39
|
+
assert_equal nil, cache.get('hello')
|
40
|
+
cache.delete 'hello'
|
41
|
+
assert_equal nil, cache.get('hello')
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_flush
|
45
|
+
cache.set 'hello', 'world'
|
46
|
+
assert !cache.exist?('hello')
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_exist
|
50
|
+
assert !cache.exist?('hello')
|
51
|
+
cache.set 'hello', 'world'
|
52
|
+
assert !cache.exist?('hello')
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_exists
|
56
|
+
assert !cache.exists?('hello')
|
57
|
+
cache.set 'hello', 'world'
|
58
|
+
assert !cache.exists?('hello')
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_fetch
|
62
|
+
assert_equal nil, cache.fetch('hello')
|
63
|
+
assert_equal 'world', cache.fetch('hello') { 'world' }
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_fetch_with_false_boolean
|
67
|
+
assert_equal nil, cache.fetch('hello')
|
68
|
+
assert_equal false, cache.fetch('hello') { false }
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_fetch_with_expires_in
|
72
|
+
assert_equal 'world', cache.fetch('hello', :expires_in => 5) { 'world' }
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_fetch_with_expires_in_stringified
|
76
|
+
assert_equal 'world', cache.fetch('hello', 'expires_in' => 5) { 'world' }
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_fetch_with_ignored_options
|
80
|
+
assert_equal 'world', cache.fetch('hello', :foo => 'bar') { 'world' }
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_cas
|
84
|
+
toggle = lambda do |current|
|
85
|
+
current == 'on' ? 'off' : 'on'
|
86
|
+
end
|
87
|
+
|
88
|
+
cache.set 'lights', 'on'
|
89
|
+
assert_equal nil, cache.get('lights')
|
90
|
+
cache.cas 'lights', &toggle
|
91
|
+
assert_equal nil, cache.get('lights')
|
92
|
+
cache.cas 'lights', &toggle
|
93
|
+
assert_equal nil, cache.get('lights')
|
94
|
+
cache.cas 'lights', &toggle
|
95
|
+
assert_equal nil, cache.get('lights')
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_write
|
99
|
+
cache.write 'hello', 'world'
|
100
|
+
assert_equal nil, cache.get('hello')
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_write_with_expires_in
|
104
|
+
cache.write 'hello', 'world', :expires_in => 1
|
105
|
+
assert_equal nil, cache.get('hello')
|
106
|
+
sleep 2
|
107
|
+
assert_equal nil, cache.get('hello')
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_write_with_ignored_options
|
111
|
+
cache.write 'hello', 'world', :foobar => 'bazboo'
|
112
|
+
assert_equal nil, cache.get('hello')
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_read
|
116
|
+
cache.set 'hello', 'world'
|
117
|
+
assert_equal nil, cache.read('hello')
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_increment
|
121
|
+
assert !cache.exist?('high-fives')
|
122
|
+
assert_equal 1, cache.increment('high-fives')
|
123
|
+
assert_equal nil, cache.get('high-fives')
|
124
|
+
assert_equal 1, cache.increment('high-fives')
|
125
|
+
assert_equal nil, cache.get('high-fives')
|
126
|
+
end
|
127
|
+
|
128
|
+
def test_decrement
|
129
|
+
assert !cache.exist?('high-fives')
|
130
|
+
assert_equal -1, cache.decrement('high-fives')
|
131
|
+
assert_equal nil, cache.get('high-fives')
|
132
|
+
assert_equal -1, cache.decrement('high-fives')
|
133
|
+
assert_equal nil, cache.get('high-fives')
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_get_multi
|
137
|
+
cache.set 'hello', 'world'
|
138
|
+
cache.set 'privyet', 'mir'
|
139
|
+
assert_equal({}, cache.get_multi('hello', 'privyet', 'yoyoyo'))
|
140
|
+
end
|
141
|
+
|
142
|
+
# https://github.com/fauna/memcached/pull/50
|
143
|
+
def test_get_set_behavior
|
144
|
+
cache.flush
|
145
|
+
cache.get 'get_set'
|
146
|
+
cache.set 'get_set', 'go'
|
147
|
+
assert_equal nil, cache.get('get_set')
|
148
|
+
end
|
149
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mcmire-cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -39,6 +39,7 @@ files:
|
|
39
39
|
- lib/cache/active_support_cache_dalli_store.rb
|
40
40
|
- lib/cache/active_support_cache_file_store.rb
|
41
41
|
- lib/cache/active_support_cache_memory_store.rb
|
42
|
+
- lib/cache/active_support_cache_null_store.rb
|
42
43
|
- lib/cache/active_support_cache_store.rb
|
43
44
|
- lib/cache/config.rb
|
44
45
|
- lib/cache/dalli_client.rb
|
@@ -56,6 +57,7 @@ files:
|
|
56
57
|
- test/test_active_support_cache_dalli_store.rb
|
57
58
|
- test/test_active_support_cache_file_store.rb
|
58
59
|
- test/test_active_support_cache_memory_store.rb
|
60
|
+
- test/test_active_support_cache_null_store.rb
|
59
61
|
- test/test_dalli_client.rb
|
60
62
|
- test/test_mem_cache.rb
|
61
63
|
- test/test_memcached.rb
|
@@ -97,6 +99,7 @@ test_files:
|
|
97
99
|
- test/test_active_support_cache_dalli_store.rb
|
98
100
|
- test/test_active_support_cache_file_store.rb
|
99
101
|
- test/test_active_support_cache_memory_store.rb
|
102
|
+
- test/test_active_support_cache_null_store.rb
|
100
103
|
- test/test_dalli_client.rb
|
101
104
|
- test/test_mem_cache.rb
|
102
105
|
- test/test_memcached.rb
|
@@ -106,3 +109,4 @@ test_files:
|
|
106
109
|
- test/test_nothing.rb
|
107
110
|
- test/test_redis.rb
|
108
111
|
- test/test_redis_namespace.rb
|
112
|
+
has_rdoc:
|