persistent-cache 0.3.8 → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
@@ -19,10 +19,7 @@ module Persistent
|
|
19
19
|
def lookup_key(serialized_key)
|
20
20
|
EH::retry!(:args => [serialized_key]) do
|
21
21
|
return [] if @storage[serialized_key].nil?
|
22
|
-
|
23
|
-
result[0][0] = @storage[serialized_key][:value]
|
24
|
-
result[0][1] = @storage[serialized_key][:timestamp]
|
25
|
-
result
|
22
|
+
[@storage[serialized_key][:value], @storage[serialized_key][:timestamp]]
|
26
23
|
end
|
27
24
|
end
|
28
25
|
|
@@ -20,10 +20,8 @@ describe Persistent::StorageRAM do
|
|
20
20
|
start_time = Time.now - 1
|
21
21
|
@iut.save_key_value_pair(Marshal.dump(@test_key), Marshal.dump(@test_value))
|
22
22
|
result = @iut.lookup_key(Marshal.dump(@test_key))
|
23
|
-
expect(result
|
24
|
-
|
25
|
-
expect(result[0][0]).to eql(Marshal.dump(@test_value))
|
26
|
-
test_time = Time.parse(result[0][1])
|
23
|
+
expect(result[0]).to eql(Marshal.dump(@test_value))
|
24
|
+
test_time = Time.parse(result[1])
|
27
25
|
expect(test_time).to be > start_time
|
28
26
|
expect(test_time).to be < start_time + 600
|
29
27
|
end
|
@@ -33,9 +31,8 @@ describe Persistent::StorageRAM do
|
|
33
31
|
@iut.save_key_value_pair(Marshal.dump(@test_key), Marshal.dump(@test_value), test_time)
|
34
32
|
result = @iut.lookup_key(Marshal.dump(@test_key))
|
35
33
|
expect(result.nil?).to eql(false)
|
36
|
-
expect(result[0]
|
37
|
-
|
38
|
-
time_retrieved = Time.parse(result[0][1])
|
34
|
+
expect(result[0]).to eql(Marshal.dump(@test_value))
|
35
|
+
time_retrieved = Time.parse(result[1])
|
39
36
|
expect(time_retrieved.to_s).to eql(test_time.to_s)
|
40
37
|
end
|
41
38
|
|
@@ -43,10 +40,7 @@ describe Persistent::StorageRAM do
|
|
43
40
|
@iut.save_key_value_pair(Marshal.dump(@test_key), Marshal.dump(@test_value))
|
44
41
|
@iut.save_key_value_pair(Marshal.dump(@test_key), Marshal.dump("testvalue2"))
|
45
42
|
result = @iut.lookup_key(Marshal.dump(@test_key))
|
46
|
-
expect(result
|
47
|
-
expect(result[0].nil?).to eql(false)
|
48
|
-
expect(result.size).to eql(1)
|
49
|
-
expect(result[0][0]).to eql(Marshal.dump("testvalue2"))
|
43
|
+
expect(result[0]).to eql(Marshal.dump("testvalue2"))
|
50
44
|
end
|
51
45
|
end
|
52
46
|
|
@@ -54,7 +48,7 @@ describe Persistent::StorageRAM do
|
|
54
48
|
it "should retrieve the value from RAM" do
|
55
49
|
@iut.save_key_value_pair(Marshal.dump(@test_key), Marshal.dump(@test_value))
|
56
50
|
result = @iut.lookup_key(Marshal.dump(@test_key))
|
57
|
-
expect(result[0]
|
51
|
+
expect(result[0]).to eql(Marshal.dump(@test_value))
|
58
52
|
end
|
59
53
|
|
60
54
|
it "should retrieve the timestamp when the value was stored from RAM" do
|
@@ -62,7 +56,7 @@ describe Persistent::StorageRAM do
|
|
62
56
|
@iut.save_key_value_pair(Marshal.dump(@test_key), Marshal.dump(@test_value))
|
63
57
|
sleep 1
|
64
58
|
result = @iut.lookup_key(Marshal.dump(@test_key))
|
65
|
-
expect(result[
|
59
|
+
expect(result[1]).to eql(now)
|
66
60
|
end
|
67
61
|
|
68
62
|
it "should return an empty array if a key is not in RAM" do
|
@@ -81,7 +75,7 @@ describe Persistent::StorageRAM do
|
|
81
75
|
it "should delete the entry if it is present" do
|
82
76
|
@iut.save_key_value_pair(Marshal.dump(@test_key), Marshal.dump(@test_value))
|
83
77
|
result = @iut.lookup_key(Marshal.dump(@test_key))
|
84
|
-
expect(result[0]
|
78
|
+
expect(result[0]).to eql(Marshal.dump(@test_value))
|
85
79
|
@iut.delete_entry(Marshal.dump(@test_key))
|
86
80
|
result = @iut.lookup_key(Marshal.dump(@test_key))
|
87
81
|
expect(result).to eql([])
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: persistent-cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-06-
|
13
|
+
date: 2015-06-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|