quetzall-cloud_cache 1.1.3 → 1.1.4
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 +19 -2
- data/test/cache_tests.rb +5 -3
- data/test/my_class.rb +9 -0
- metadata +3 -2
data/lib/cloud_cache.rb
CHANGED
|
@@ -124,16 +124,28 @@ module ActiveSupport
|
|
|
124
124
|
values = {}
|
|
125
125
|
curr_key = nil
|
|
126
126
|
data_length = 0
|
|
127
|
+
val = ""
|
|
128
|
+
count = 0
|
|
127
129
|
body.each_line do |line|
|
|
128
|
-
|
|
130
|
+
# print 'LINE=' + line
|
|
131
|
+
if line == "END\r\n"
|
|
132
|
+
# puts 'ENDED!!!'
|
|
133
|
+
break
|
|
134
|
+
end
|
|
129
135
|
if line =~ /^VALUE (.+) (.+)/ then # (key) (bytes)
|
|
136
|
+
if !curr_key.nil?
|
|
137
|
+
values[curr_key] = raw ? val.strip : Marshal.load(val.strip)
|
|
138
|
+
end
|
|
130
139
|
curr_key, data_length = $1, $2
|
|
140
|
+
val = ""
|
|
131
141
|
#raise CloudCacheError, "Unexpected response #{line.inspect}"
|
|
132
142
|
else
|
|
133
143
|
# data block
|
|
134
|
-
|
|
144
|
+
val += line
|
|
135
145
|
end
|
|
146
|
+
count += 1
|
|
136
147
|
end
|
|
148
|
+
values[curr_key] = raw ? val.strip : Marshal.load(val.strip)
|
|
137
149
|
#puts 'values=' + values.inspect
|
|
138
150
|
values
|
|
139
151
|
end
|
|
@@ -163,6 +175,7 @@ module ActiveSupport
|
|
|
163
175
|
|
|
164
176
|
def list_keys
|
|
165
177
|
body = run_http(:get, "listkeys", "listkeys")
|
|
178
|
+
# puts "list_keys=" + body
|
|
166
179
|
keys = ActiveSupport::JSON.decode body # body[1..-2].split(',').collect! {|n| n.to_i}
|
|
167
180
|
keys
|
|
168
181
|
end
|
|
@@ -205,6 +218,10 @@ module ActiveSupport
|
|
|
205
218
|
end
|
|
206
219
|
|
|
207
220
|
def exist?(key, options = nil)
|
|
221
|
+
exists?(key, options)
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
def exists?(key, options = nil)
|
|
208
225
|
x = get(key, true)
|
|
209
226
|
return !x.nil?
|
|
210
227
|
end
|
data/test/cache_tests.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require 'test/unit'
|
|
2
2
|
require '../lib/cloud_cache'
|
|
3
|
-
|
|
3
|
+
require 'my_class'
|
|
4
4
|
#
|
|
5
5
|
# You'll need make a cloudcache.yml file in this directory that contains:
|
|
6
6
|
# amazon:
|
|
@@ -90,7 +90,7 @@ class CacheTests < Test::Unit::TestCase
|
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
def test_list_keys
|
|
93
|
-
@cache.put("k1", "v2")
|
|
93
|
+
@cache.put("k1", "v2", 1000)
|
|
94
94
|
sleep 1
|
|
95
95
|
keys = @cache.list_keys
|
|
96
96
|
puts("PRINTING KEYS:")
|
|
@@ -150,13 +150,15 @@ class CacheTests < Test::Unit::TestCase
|
|
|
150
150
|
def test_get_multi
|
|
151
151
|
@cache.put("m1", "v1", 500, false)
|
|
152
152
|
@cache.put("m2", "v2", 500, false)
|
|
153
|
+
@cache.put("m4", MyClass.new("Travis", 10), 500, false)
|
|
153
154
|
|
|
154
|
-
kz = Array["m1", "m2", "m3"]
|
|
155
|
+
kz = Array["m1", "m2", "m3", "m4"]
|
|
155
156
|
vz = @cache.get_multi(kz)
|
|
156
157
|
|
|
157
158
|
assert_equal("v1", vz["m1"]);
|
|
158
159
|
assert_equal("v2", vz["m2"]);
|
|
159
160
|
assert_nil(vz["m3"]);
|
|
161
|
+
assert_equal("Travis", vz["m4"].name, vz["m4"].age)
|
|
160
162
|
end
|
|
161
163
|
|
|
162
164
|
|
data/test/my_class.rb
ADDED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: quetzall-cloud_cache
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.4
|
|
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-07-14 00:00:00 -07:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies: []
|
|
15
15
|
|
|
@@ -54,5 +54,6 @@ specification_version: 2
|
|
|
54
54
|
summary: Client library for Quetzall's CloudCache service.
|
|
55
55
|
test_files:
|
|
56
56
|
- test/cache_tests.rb
|
|
57
|
+
- test/my_class.rb
|
|
57
58
|
- test/test_cloud_cache.rb
|
|
58
59
|
- test/test_runner.rb
|