atomic_cache 0.2.2.rc1 → 0.2.3.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/atomic_cache/storage/dalli.rb +2 -7
- data/lib/atomic_cache/version.rb +1 -1
- data/spec/atomic_cache/storage/dalli_spec.rb +3 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da4480539afcbe1c7c15e34dfbd77c7da40761853fc270bab1a0ad6d778b253e
|
4
|
+
data.tar.gz: c0deb89b6a828430252b6ae85d1727aa5282837b355013f661be6f100406125b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1aacd6f8ac2f420ac3b87e3d3031533f0cd3268cd6cb567a22e990c860274a6640800c4cfd4a88481b90af5c40ef60101d699a2a2df348fbe60e8e4639dd6901
|
7
|
+
data.tar.gz: c405dbd590e3f3f095a25ca1189687548cdf09380bba0b390060560b555730eade8528f897665d99d50a2ac0783ca00bd96e4029d852fbd79ffe14cd38daee0c
|
@@ -10,10 +10,6 @@ module AtomicCache
|
|
10
10
|
class Dalli < Store
|
11
11
|
extend Forwardable
|
12
12
|
|
13
|
-
ADD_SUCCESS = 'STORED'
|
14
|
-
ADD_UNSUCCESSFUL = 'NOT_STORED'
|
15
|
-
ADD_EXISTS = 'EXISTS'
|
16
|
-
|
17
13
|
def_delegators :@dalli_client, :delete
|
18
14
|
|
19
15
|
def initialize(dalli_client)
|
@@ -27,8 +23,7 @@ module AtomicCache
|
|
27
23
|
# dalli expects time in seconds
|
28
24
|
# https://github.com/petergoldstein/dalli/blob/b8f4afe165fb3e07294c36fb1c63901b0ed9ce10/lib/dalli/client.rb#L27
|
29
25
|
# TODO: verify this unit is being treated correctly through the system
|
30
|
-
|
31
|
-
response.start_with?(ADD_SUCCESS)
|
26
|
+
!!@dalli_client.add(key, new_value, ttl, opts)
|
32
27
|
end
|
33
28
|
|
34
29
|
def read(key, user_options={})
|
@@ -38,7 +33,7 @@ module AtomicCache
|
|
38
33
|
def set(key, value, user_options={})
|
39
34
|
ttl = user_options[:ttl]
|
40
35
|
user_options.delete(:ttl)
|
41
|
-
|
36
|
+
!!@dalli_client.set(key, value, ttl, user_options)
|
42
37
|
end
|
43
38
|
|
44
39
|
end
|
data/lib/atomic_cache/version.rb
CHANGED
@@ -37,7 +37,7 @@ describe 'Dalli' do
|
|
37
37
|
|
38
38
|
context '#add' do
|
39
39
|
before(:each) do
|
40
|
-
allow(dalli_client).to receive(:add).and_return(
|
40
|
+
allow(dalli_client).to receive(:add).and_return(false)
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'delegates to #add with the raw option set' do
|
@@ -47,22 +47,17 @@ describe 'Dalli' do
|
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'returns true when the add is successful' do
|
50
|
-
expect(dalli_client).to receive(:add).and_return(
|
50
|
+
expect(dalli_client).to receive(:add).and_return(12339031748204560384)
|
51
51
|
result = subject.add('key', 'value', 100)
|
52
52
|
expect(result).to eq(true)
|
53
53
|
end
|
54
54
|
|
55
55
|
it 'returns false if the key already exists' do
|
56
|
-
expect(dalli_client).to receive(:add).and_return(
|
56
|
+
expect(dalli_client).to receive(:add).and_return(false)
|
57
57
|
result = subject.add('key', 'value', 100)
|
58
58
|
expect(result).to eq(false)
|
59
59
|
end
|
60
60
|
|
61
|
-
it 'returns false if the add fails' do
|
62
|
-
expect(dalli_client).to receive(:add).and_return('NOT_STORED\r\n')
|
63
|
-
result = subject.add('key', 'value', 100)
|
64
|
-
expect(result).to eq(false)
|
65
|
-
end
|
66
61
|
end
|
67
62
|
|
68
63
|
end
|