cloud_cache 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/cloud_cache.rb +54 -7
- metadata +2 -2
data/lib/cloud_cache.rb
CHANGED
@@ -12,11 +12,11 @@ module ActiveSupport
|
|
12
12
|
|
13
13
|
class CloudCache < Store
|
14
14
|
|
15
|
-
VERSION = '1.0.
|
15
|
+
VERSION = '1.0.2'
|
16
16
|
|
17
17
|
attr_accessor :secret_key
|
18
18
|
|
19
|
-
def initialize(
|
19
|
+
def initialize(access_key, secret_key)
|
20
20
|
puts 'Creating new CloudCache'
|
21
21
|
@access_key = access_key
|
22
22
|
@secret_key = secret_key
|
@@ -93,6 +93,16 @@ module ActiveSupport
|
|
93
93
|
end
|
94
94
|
|
95
95
|
|
96
|
+
def get_multi(keys)
|
97
|
+
kj = keys.to_json
|
98
|
+
puts "keys.to_json = " + kj
|
99
|
+
extra_headers = {"keys" => kj }
|
100
|
+
puts "get_multi, extra_headers keys = " + extra_headers.keys.to_s
|
101
|
+
puts "get_multi, extra_headers vals = " + extra_headers.values.to_s
|
102
|
+
body = run_http(:get, "GET", "getmulti" , nil,nil,extra_headers)
|
103
|
+
vals = ActiveSupport::JSON.decode body
|
104
|
+
vals
|
105
|
+
end
|
96
106
|
def get(key)
|
97
107
|
|
98
108
|
begin
|
@@ -131,6 +141,22 @@ module ActiveSupport
|
|
131
141
|
keys
|
132
142
|
end
|
133
143
|
|
144
|
+
def stats
|
145
|
+
body = run_http(:get, "mystats", "mystats")
|
146
|
+
#keys = ActiveSupport::JSON.decode body # body[1..-2].split(',').collect! {|n| n.to_i}
|
147
|
+
body
|
148
|
+
end
|
149
|
+
|
150
|
+
|
151
|
+
def flush
|
152
|
+
body = run_http(:get, "flush", "flush")
|
153
|
+
body.strip
|
154
|
+
end
|
155
|
+
|
156
|
+
def clear
|
157
|
+
flush
|
158
|
+
end
|
159
|
+
|
134
160
|
def read(name, options = nil)
|
135
161
|
# puts 'read from localcache'
|
136
162
|
super
|
@@ -152,19 +178,40 @@ module ActiveSupport
|
|
152
178
|
|
153
179
|
def delete_matched(matcher, options = nil)
|
154
180
|
super
|
155
|
-
raise "delete_matched not supported by
|
181
|
+
raise "delete_matched not yet supported by CloudCache"
|
156
182
|
end
|
157
183
|
|
158
|
-
def
|
159
|
-
|
184
|
+
def exist?(key, options = nil)
|
185
|
+
x = get(key)
|
186
|
+
r = true
|
187
|
+
if (x == nil)
|
188
|
+
r = false
|
189
|
+
end
|
190
|
+
r
|
191
|
+
end
|
192
|
+
|
193
|
+
def fetch(key , options = {})
|
194
|
+
if (options != {})
|
195
|
+
raise "Options on fetch() not yet supported by this library"
|
196
|
+
end
|
197
|
+
v = get(key)
|
198
|
+
v
|
199
|
+
end
|
200
|
+
|
201
|
+
def increment(key,val=1)
|
202
|
+
ret = run_http(:post, "POST", key + "/incr", nil, {"val"=>val})
|
160
203
|
ret.to_i
|
161
204
|
end
|
162
205
|
|
163
|
-
def decrement(key)
|
164
|
-
ret = run_http(:post, "POST", key + "/decr", nil, {"val"=>
|
206
|
+
def decrement(key,val=1)
|
207
|
+
ret = run_http(:post, "POST", key + "/decr", nil, {"val"=>val})
|
165
208
|
ret.to_i
|
166
209
|
end
|
167
210
|
|
211
|
+
def silence!
|
212
|
+
super
|
213
|
+
end
|
214
|
+
|
168
215
|
def shutdown
|
169
216
|
|
170
217
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloud_cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Travis Reeder
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-05-27 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|