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 +4 -4
- data/docs/USAGE.md +8 -0
- data/lib/atomic_cache/storage/dalli.rb +4 -2
- data/lib/atomic_cache/version.rb +1 -1
- data/spec/atomic_cache/storage/dalli_spec.rb +11 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb65136822683212f95725ed2a56753b369cabc3ff68335310755f465e997dc7
|
4
|
+
data.tar.gz: 891410bc30fcb78b0b8850913b7d3e2c70eff9d2063df3e76c233a3685a6c55e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
35
|
+
@dalli_client.get(key, user_options)
|
36
36
|
end
|
37
37
|
|
38
38
|
def set(key, value, user_options={})
|
39
|
-
|
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
|
data/lib/atomic_cache/version.rb
CHANGED
@@ -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
|
-
|
17
|
-
|
18
|
-
|
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(:
|
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.
|
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-
|
12
|
+
date: 2021-06-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|