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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb65136822683212f95725ed2a56753b369cabc3ff68335310755f465e997dc7
4
- data.tar.gz: 891410bc30fcb78b0b8850913b7d3e2c70eff9d2063df3e76c233a3685a6c55e
3
+ metadata.gz: da4480539afcbe1c7c15e34dfbd77c7da40761853fc270bab1a0ad6d778b253e
4
+ data.tar.gz: c0deb89b6a828430252b6ae85d1727aa5282837b355013f661be6f100406125b
5
5
  SHA512:
6
- metadata.gz: 13b9b39ea19ad6e157e6015a4e2670df741f9106d36b0f64931da60d651ecd61abd39c24183fb648498f3d4d54ab92684c389ced188650a61f6c2dcc7170748d
7
- data.tar.gz: e33b8ded8491885eb96508e678ddb8bbc7f62f691c795fbcbaa9303c0a6e578f5666793c64ca1db8b0fbf98a0d9257f1eb68653c0f862d416bf3d6b65fa012b3
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
- response = @dalli_client.add(key, new_value, ttl, opts)
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
- @dalli_client.set(key, value, ttl, user_options)
36
+ !!@dalli_client.set(key, value, ttl, user_options)
42
37
  end
43
38
 
44
39
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AtomicCache
4
- VERSION = "0.2.2.rc1"
4
+ VERSION = "0.2.3.rc1"
5
5
  end
@@ -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('NOT_STORED\r\n')
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('STORED\r\n')
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('EXISTS\r\n')
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atomic_cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2.rc1
4
+ version: 0.2.3.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ibotta Developers