atomic_cache 0.2.1.rc2 → 0.2.2.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: 89d82475dddde4fb324d6f2187d47122916dc381883fedcfec2ff00204035e08
4
- data.tar.gz: 34d5d998acee788561e3e49019d5983fed4226e4cf88ba7cb0d8fe7cb2bd5a3b
3
+ metadata.gz: bb65136822683212f95725ed2a56753b369cabc3ff68335310755f465e997dc7
4
+ data.tar.gz: 891410bc30fcb78b0b8850913b7d3e2c70eff9d2063df3e76c233a3685a6c55e
5
5
  SHA512:
6
- metadata.gz: e19f7c43629d01ebeceba040c818a8ae75f183245e9171d3ab39a3d302388769f263292ae04d39c1dcc01137190181f27f5628b3f091a26808c1767ce85ba24e
7
- data.tar.gz: b5d0036456849d3d882227231908da8e885e1e6772f4e0b1a4b121a3690e34acd0f0b4ce5a67816c5fc62b5e053100d8c93980b0e8252f693f8737e42bed60e7
6
+ metadata.gz: 13b9b39ea19ad6e157e6015a4e2670df741f9106d36b0f64931da60d651ecd61abd39c24183fb648498f3d4d54ab92684c389ced188650a61f6c2dcc7170748d
7
+ data.tar.gz: e33b8ded8491885eb96508e678ddb8bbc7f62f691c795fbcbaa9303c0a6e578f5666793c64ca1db8b0fbf98a0d9257f1eb68653c0f862d416bf3d6b65fa012b3
data/docs/USAGE.md CHANGED
@@ -21,6 +21,14 @@ end
21
21
 
22
22
  In addition to the below options, any other options given (e.g. `expires_in`, `cache_nils`) are passed through to the underlying storage adapter. This allows storage-specific options to be passed through (reference: [Dalli config](https://github.com/petergoldstein/dalli#configuration)).
23
23
 
24
+ #### TTL
25
+ Various storage clients require TTL to be expressed in different ways. The included storage adapters will unwrap the `ttl` option to an storage-specific representation.
26
+ ```ruby
27
+ atomic_cache.fetch(ttl: 500) do
28
+ # generate block
29
+ end
30
+ ```
31
+
24
32
  #### `generate_ttl_ms`
25
33
  _Defaults to 30 seconds._
26
34
 
@@ -32,11 +32,13 @@ module AtomicCache
32
32
  end
33
33
 
34
34
  def read(key, user_options={})
35
- @dalli_client.read(key, user_options)
35
+ @dalli_client.get(key, user_options)
36
36
  end
37
37
 
38
38
  def set(key, value, user_options={})
39
- @dalli_client.set(key, value, user_options)
39
+ ttl = user_options[:ttl]
40
+ user_options.delete(:ttl)
41
+ @dalli_client.set(key, value, ttl, user_options)
40
42
  end
41
43
 
42
44
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AtomicCache
4
- VERSION = "0.2.1.rc2"
4
+ VERSION = "0.2.2.rc1"
5
5
  end
@@ -13,13 +13,20 @@ describe 'Dalli' do
13
13
  let(:dalli_client) { FakeDalli.new }
14
14
  subject { AtomicCache::Storage::Dalli.new(dalli_client) }
15
15
 
16
- it 'delegates #set without options' do
17
- expect(dalli_client).to receive(:set).with('key', 'value', {})
18
- subject.set('key', 'value')
16
+ context '#set' do
17
+ it 'delegates #set without options' do
18
+ expect(dalli_client).to receive(:set).with('key', 'value', nil, {})
19
+ subject.set('key', 'value')
20
+ end
21
+
22
+ it 'delegates #set with TTL' do
23
+ expect(dalli_client).to receive(:set).with('key', 'value', 500, {})
24
+ subject.set('key', 'value', { ttl: 500 })
25
+ end
19
26
  end
20
27
 
21
28
  it 'delegates #read without options' do
22
- expect(dalli_client).to receive(:read).with('key', {}).and_return('asdf')
29
+ expect(dalli_client).to receive(:get).with('key', {}).and_return('asdf')
23
30
  subject.read('key')
24
31
  end
25
32
 
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.1.rc2
4
+ version: 0.2.2.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ibotta Developers
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-06-22 00:00:00.000000000 Z
12
+ date: 2021-06-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler