iron_cache 1.2.3 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +2 -2
- data/lib/active_support/cache/iron_cache_store.rb +2 -1
- data/lib/iron_cache/caches.rb +14 -3
- data/lib/iron_cache/items.rb +1 -1
- data/lib/iron_cache/version.rb +1 -1
- data/test/test_iron_cache.rb +33 -0
- data/test/tmp.rb +16 -11
- metadata +2 -2
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
iron_cache (1.2.
|
4
|
+
iron_cache (1.2.3)
|
5
5
|
iron_core (>= 0.4.2)
|
6
6
|
|
7
7
|
GEM
|
@@ -12,7 +12,7 @@ GEM
|
|
12
12
|
memcache-client (1.8.5)
|
13
13
|
mime-types (1.19)
|
14
14
|
minitest (4.1.0)
|
15
|
-
net-http-persistent (2.
|
15
|
+
net-http-persistent (2.8)
|
16
16
|
rake (0.9.2.2)
|
17
17
|
rest (2.0.4)
|
18
18
|
net-http-persistent
|
@@ -76,6 +76,7 @@ module ActiveSupport
|
|
76
76
|
|
77
77
|
def deserialize_entry(raw_value)
|
78
78
|
if raw_value
|
79
|
+
raw_value = ::Base64.decode64(raw_value) rescue raw_value
|
79
80
|
entry = Marshal.load(raw_value) rescue raw_value
|
80
81
|
entry.is_a?(ActiveSupport::Cache::Entry) ? entry : ActiveSupport::Cache::Entry.new(entry)
|
81
82
|
else
|
@@ -93,7 +94,7 @@ module ActiveSupport
|
|
93
94
|
value = entry.to_s
|
94
95
|
end
|
95
96
|
else
|
96
|
-
value = Marshal.dump(entry)
|
97
|
+
value = ::Base64.encode64 Marshal.dump(entry)
|
97
98
|
end
|
98
99
|
end
|
99
100
|
end
|
data/lib/iron_cache/caches.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'cgi'
|
2
2
|
|
3
3
|
module IronCache
|
4
4
|
class Caches
|
@@ -12,7 +12,7 @@ module IronCache
|
|
12
12
|
def path(options={})
|
13
13
|
path = "projects/#{@client.project_id}/caches"
|
14
14
|
if options[:name]
|
15
|
-
path << "/#{
|
15
|
+
path << "/#{CGI::escape(options[:name])}"
|
16
16
|
end
|
17
17
|
path
|
18
18
|
end
|
@@ -38,10 +38,17 @@ module IronCache
|
|
38
38
|
options = {:name=>options}
|
39
39
|
end
|
40
40
|
options[:name] ||= @client.cache_name
|
41
|
-
res = @client.parse_response(@client.get(
|
41
|
+
res = @client.parse_response(@client.get(path(options)))
|
42
42
|
Cache.new(@client, res)
|
43
43
|
end
|
44
44
|
|
45
|
+
def clear(options={})
|
46
|
+
res = @client.post(path(options) + "/clear")
|
47
|
+
json = @client.parse_response(res, true)
|
48
|
+
#return Message.new(self, res)
|
49
|
+
return ResponseBase.new(json)
|
50
|
+
end
|
51
|
+
|
45
52
|
|
46
53
|
end
|
47
54
|
|
@@ -108,6 +115,10 @@ module IronCache
|
|
108
115
|
@client.items.increment(k, amount, options.merge(:cache_name=>name))
|
109
116
|
end
|
110
117
|
|
118
|
+
def clear(options={})
|
119
|
+
@client.caches.clear(options.merge(:name=>name))
|
120
|
+
end
|
121
|
+
|
111
122
|
end
|
112
123
|
|
113
124
|
end
|
data/lib/iron_cache/items.rb
CHANGED
data/lib/iron_cache/version.rb
CHANGED
data/test/test_iron_cache.rb
CHANGED
@@ -177,5 +177,38 @@ class IronCacheTests < TestBase
|
|
177
177
|
end
|
178
178
|
|
179
179
|
|
180
|
+
def test_keys
|
181
|
+
@client.cache_name = 'test_keys'
|
182
|
+
clear_queue
|
183
|
+
|
184
|
+
k = "word_count_[EBook"
|
185
|
+
v = "hello world!"
|
186
|
+
res = @client.items.put(k, v)
|
187
|
+
# another naming option we could try:
|
188
|
+
#res = @client.cache('test_basics').items.put("key1", "hello world!")
|
189
|
+
p res
|
190
|
+
assert res.msg
|
191
|
+
|
192
|
+
end
|
193
|
+
|
194
|
+
|
195
|
+
def test_clear
|
196
|
+
cache = @client.cache("test_clear")
|
197
|
+
num_items = 50
|
198
|
+
|
199
|
+
num_items.times do |i|
|
200
|
+
res = cache.put("key-#{i}", "value")
|
201
|
+
end
|
202
|
+
|
203
|
+
tkey = "key-0"
|
204
|
+
assert_equal "value", cache.get(tkey).value
|
205
|
+
puts "cache.size: #{cache.size}"
|
206
|
+
assert_equal num_items, cache.size
|
207
|
+
|
208
|
+
p cache.clear
|
209
|
+
assert_nil cache.get(tkey)
|
210
|
+
assert_equal 0, cache.reload.size
|
211
|
+
end
|
212
|
+
|
180
213
|
end
|
181
214
|
|
data/test/tmp.rb
CHANGED
@@ -8,18 +8,23 @@ class IronCacheTests < TestBase
|
|
8
8
|
super
|
9
9
|
end
|
10
10
|
|
11
|
-
def test_keys
|
12
|
-
@client.cache_name = 'test_keys'
|
13
|
-
clear_queue
|
14
|
-
|
15
|
-
k = "word_count_[EBook"
|
16
|
-
v = "hello world!"
|
17
|
-
res = @client.items.put(k, v)
|
18
|
-
# another naming option we could try:
|
19
|
-
#res = @client.cache('test_basics').items.put("key1", "hello world!")
|
20
|
-
p res
|
21
|
-
assert res.msg
|
22
11
|
|
12
|
+
def test_clear
|
13
|
+
cache = @client.cache("test_clear")
|
14
|
+
num_items = 50
|
15
|
+
|
16
|
+
num_items.times do |i|
|
17
|
+
res = cache.put("key-#{i}", "value")
|
18
|
+
end
|
19
|
+
|
20
|
+
tkey = "key-0"
|
21
|
+
assert_equal "value", cache.get(tkey).value
|
22
|
+
puts "cache.size: #{cache.size}"
|
23
|
+
assert_equal num_items, cache.size
|
24
|
+
|
25
|
+
p cache.clear
|
26
|
+
assert_nil cache.get(tkey)
|
27
|
+
assert_equal 0, cache.reload.size
|
23
28
|
end
|
24
29
|
|
25
30
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iron_cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: iron_core
|