any_cache 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/.travis.yml +24 -24
- data/CHANGELOG.md +8 -0
- data/README.md +66 -16
- data/any_cache.gemspec +3 -3
- data/bin/rspec +1 -1
- data/lib/any_cache.rb +2 -0
- data/lib/any_cache/adapters/active_support_dalli_store.rb +17 -13
- data/lib/any_cache/adapters/active_support_mem_cache_store.rb +25 -12
- data/lib/any_cache/adapters/active_support_naive_store.rb +9 -0
- data/lib/any_cache/adapters/active_support_redis_cache_store.rb +29 -15
- data/lib/any_cache/adapters/basic.rb +11 -0
- data/lib/any_cache/adapters/dalli.rb +35 -10
- data/lib/any_cache/adapters/delegator.rb +6 -4
- data/lib/any_cache/adapters/redis.rb +28 -7
- data/lib/any_cache/adapters/redis_store.rb +12 -6
- data/lib/any_cache/delegation.rb +1 -1
- data/lib/any_cache/dumper.rb +55 -0
- data/lib/any_cache/dumper/interface_access_mixin.rb +41 -0
- data/lib/any_cache/patches/dalli_store.rb +0 -1
- data/lib/any_cache/version.rb +1 -1
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90ca0569d3cc57ab74792f1ba11226b508a7d465c3c7f8a669e46d4a64501fbf
|
4
|
+
data.tar.gz: 877f5ec51869e4788a99e2d416a9d818cf53427710e3249b8619304a89e2515f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04a47243ee066a715bb1d6b5116d936168e84f35bf95cf38625a790d652c7a0f613e158d8134f261a1adcda4af765d072adac84ce08cf3a57f6b61b0efa60702
|
7
|
+
data.tar.gz: 7cff2361d74b63a00384a1d250d7ba60175c1cd3bc31fa7cf216eadf7d8e332b360bdc41ef5d6ab5af1a2d0c0d020a1b8410f0fdf48fbf729fe4ad8627130b9e
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
@@ -10,97 +10,97 @@ services:
|
|
10
10
|
matrix:
|
11
11
|
fast_finish: true
|
12
12
|
include:
|
13
|
-
- rvm: 2.3.
|
13
|
+
- rvm: 2.3.8
|
14
14
|
gemfile: gemfiles/active_support.gemfile
|
15
15
|
env: TEST_AS_MEMORY_STORE_CACHE=true
|
16
|
-
- rvm: 2.4.
|
16
|
+
- rvm: 2.4.5
|
17
17
|
gemfile: gemfiles/active_support.gemfile
|
18
18
|
env: TEST_AS_MEMORY_STORE_CACHE=true
|
19
|
-
- rvm: 2.5.
|
19
|
+
- rvm: 2.5.3
|
20
20
|
gemfile: gemfiles/active_support.gemfile
|
21
21
|
env: TEST_AS_MEMORY_STORE_CACHE=true
|
22
22
|
- rvm: ruby-head
|
23
23
|
gemfile: gemfiles/active_support.gemfile
|
24
24
|
env: TEST_AS_MEMORY_STORE_CACHE=true
|
25
|
-
- rvm: 2.3.
|
25
|
+
- rvm: 2.3.8
|
26
26
|
gemfile: gemfiles/active_support.gemfile
|
27
27
|
env: TEST_AS_FILE_STORE_CACHE=true
|
28
|
-
- rvm: 2.4.
|
28
|
+
- rvm: 2.4.5
|
29
29
|
gemfile: gemfiles/active_support.gemfile
|
30
30
|
env: TEST_AS_FILE_STORE_CACHE=true
|
31
|
-
- rvm: 2.5.
|
31
|
+
- rvm: 2.5.3
|
32
32
|
gemfile: gemfiles/active_support.gemfile
|
33
33
|
env: TEST_AS_FILE_STORE_CACHE=true
|
34
34
|
- rvm: ruby-head
|
35
35
|
gemfile: gemfiles/active_support.gemfile
|
36
36
|
env: TEST_AS_FILE_STORE_CACHE=true
|
37
|
-
- rvm: 2.3.
|
37
|
+
- rvm: 2.3.8
|
38
38
|
gemfile: gemfiles/active_support_with_redis.gemfile
|
39
39
|
env: TEST_AS_REDIS_CACHE_STORE_CACHE=true
|
40
|
-
- rvm: 2.4.
|
40
|
+
- rvm: 2.4.5
|
41
41
|
gemfile: gemfiles/active_support_with_redis.gemfile
|
42
42
|
env: TEST_AS_REDIS_CACHE_STORE_CACHE=true
|
43
|
-
- rvm: 2.5.
|
43
|
+
- rvm: 2.5.3
|
44
44
|
gemfile: gemfiles/active_support_with_redis.gemfile
|
45
45
|
env: TEST_AS_REDIS_CACHE_STORE_CACHE=true
|
46
46
|
- rvm: ruby-head
|
47
47
|
gemfile: gemfiles/active_support_with_redis.gemfile
|
48
48
|
env: TEST_AS_REDIS_CACHE_STORE_CACHE=true
|
49
|
-
- rvm: 2.3.
|
49
|
+
- rvm: 2.3.8
|
50
50
|
gemfile: gemfiles/dalli.gemfile
|
51
51
|
env: TEST_DALLI_CACHE=true
|
52
|
-
- rvm: 2.4.
|
52
|
+
- rvm: 2.4.5
|
53
53
|
gemfile: gemfiles/dalli.gemfile
|
54
54
|
env: TEST_DALLI_CACHE=true
|
55
|
-
- rvm: 2.5.
|
55
|
+
- rvm: 2.5.3
|
56
56
|
gemfile: gemfiles/dalli.gemfile
|
57
57
|
env: TEST_DALLI_CACHE=true
|
58
58
|
- rvm: ruby-head
|
59
59
|
gemfile: gemfiles/dalli.gemfile
|
60
60
|
env: TEST_DALLI_CACHE=true
|
61
|
-
- rvm: 2.3.
|
61
|
+
- rvm: 2.3.8
|
62
62
|
gemfile: gemfiles/redis_store.gemfile
|
63
63
|
env: TEST_REDIS_STORE_CACHE=true
|
64
|
-
- rvm: 2.4.
|
64
|
+
- rvm: 2.4.5
|
65
65
|
gemfile: gemfiles/redis_store.gemfile
|
66
66
|
env: TEST_REDIS_STORE_CACHE=true
|
67
|
-
- rvm: 2.5.
|
67
|
+
- rvm: 2.5.3
|
68
68
|
gemfile: gemfiles/redis_store.gemfile
|
69
69
|
env: TEST_REDIS_STORE_CACHE=true
|
70
70
|
- rvm: ruby-head
|
71
71
|
gemfile: gemfiles/redis_store.gemfile
|
72
72
|
env: TEST_REDIS_STORE_CACHE=true
|
73
|
-
- rvm: 2.3.
|
73
|
+
- rvm: 2.3.8
|
74
74
|
gemfile: gemfiles/active_support_with_dalli.gemfile
|
75
75
|
env: TEST_AS_DALLI_STORE=true
|
76
|
-
- rvm: 2.4.
|
76
|
+
- rvm: 2.4.5
|
77
77
|
gemfile: gemfiles/active_support_with_dalli.gemfile
|
78
78
|
env: TEST_AS_DALLI_STORE=true
|
79
|
-
- rvm: 2.5.
|
79
|
+
- rvm: 2.5.3
|
80
80
|
gemfile: gemfiles/active_support_with_dalli.gemfile
|
81
81
|
env: TEST_AS_DALLI_STORE=true
|
82
82
|
- rvm: ruby-head
|
83
83
|
gemfile: gemfiles/active_support_with_dalli.gemfile
|
84
84
|
env: TEST_AS_DALLI_STORE=true
|
85
|
-
- rvm: 2.3.
|
85
|
+
- rvm: 2.3.8
|
86
86
|
gemfile: gemfiles/redis_store.gemfile
|
87
87
|
env: TEST_REDIS_CACHE=true
|
88
|
-
- rvm: 2.4.
|
88
|
+
- rvm: 2.4.5
|
89
89
|
gemfile: gemfiles/redis_store.gemfile
|
90
90
|
env: TEST_REDIS_CACHE=true
|
91
|
-
- rvm: 2.5.
|
91
|
+
- rvm: 2.5.3
|
92
92
|
gemfile: gemfiles/redis_store.gemfile
|
93
93
|
env: TEST_REDIS_CACHE=true
|
94
94
|
- rvm: ruby-head
|
95
95
|
gemfile: gemfiles/redis_store.gemfile
|
96
96
|
env: TEST_REDIS_CACHE=true
|
97
|
-
- rvm: 2.3.
|
97
|
+
- rvm: 2.3.8
|
98
98
|
gemfile: gemfiles/active_support_with_dalli.gemfile
|
99
99
|
env: TEST_AS_MEM_CACHE_STORE_CACHE=true
|
100
|
-
- rvm: 2.4.
|
100
|
+
- rvm: 2.4.5
|
101
101
|
gemfile: gemfiles/active_support_with_dalli.gemfile
|
102
102
|
env: TEST_AS_MEM_CACHE_STORE_CACHE=true
|
103
|
-
- rvm: 2.5.
|
103
|
+
- rvm: 2.5.3
|
104
104
|
gemfile: gemfiles/active_support_with_dalli.gemfile
|
105
105
|
env: TEST_AS_MEM_CACHE_STORE_CACHE=true
|
106
106
|
- rvm: ruby-head
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
# Changelog
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
+
## [0.4.0] - 2018-12-04
|
5
|
+
- `AnyCache#cleanup` - remove expired entries manually
|
6
|
+
(make sence only for `:as_file_store` and `:as_memory_store` at this moment);
|
7
|
+
- automatic object marshaling (used in `fetch`, `fetch_multi`, `write`, `write_multi`, `read`, `read_multi`):
|
8
|
+
- used by default (`raw: false`);
|
9
|
+
- can be disabled via `raw: true` option;
|
10
|
+
- `raw: true` is required for incrementable/decrementable entries;
|
11
|
+
|
4
12
|
## [0.3.1] - 2018-10-08
|
5
13
|
### Added
|
6
14
|
- patch interface `AnyCache.enable_patch!(:patch_series_name)`:
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# AnyCache · [](https://badge.fury.io/rb/any_cache) [](https://travis-ci.org/0exp/any_cache) [](https://coveralls.io/github/0exp/any_cache?branch=master)
|
2
2
|
|
3
3
|
AnyCache - a simplest cache wrapper that provides a minimalistic generic interface for all well-known cache storages and includes a minimal set of necessary operations:
|
4
|
-
`fetch`, `read`, `write`, `delete`, `fetch_multi`, `read_multi`, `write_multi`, `delete_matched`, `expire`, `persist`, `exist?`, `clear`, `increment`, `decrement`.
|
4
|
+
`fetch`, `read`, `write`, `delete`, `fetch_multi`, `read_multi`, `write_multi`, `delete_matched`, `expire`, `persist`, `exist?`, `clear`, `cleanup`, `increment`, `decrement`.
|
5
5
|
|
6
6
|
Supported clients:
|
7
7
|
|
@@ -60,6 +60,7 @@ require 'any_cache'
|
|
60
60
|
- [Persist](#persist)
|
61
61
|
- [Existence](#existence)
|
62
62
|
- [Clear](#clear)
|
63
|
+
- [Cleanup](#cleanup)
|
63
64
|
- [Roadmap](#roadmap)
|
64
65
|
|
65
66
|
---
|
@@ -196,7 +197,7 @@ require 'dalli'
|
|
196
197
|
require 'active_support'
|
197
198
|
require 'any_cache'
|
198
199
|
|
199
|
-
AnyCache.enable_patch!(:dalli_store)
|
200
|
+
AnyCache.enable_patch!(:dalli_store) # NOTE: actual for Dalli <= 2.7.8
|
200
201
|
|
201
202
|
AnyCache.configure do |conf|
|
202
203
|
conf.driver = :as_dalli_store
|
@@ -290,6 +291,7 @@ If you want to use your own cache client implementation, you should provide an o
|
|
290
291
|
- `#persist(key, [**options])` ([doc](#persist))
|
291
292
|
- `#exist?(key, [**options])` ([doc](#existence))
|
292
293
|
- `#clear([**options])` ([doc](#clear))
|
294
|
+
- `#cleanup([**options])` ([doc](#cleanup))
|
293
295
|
|
294
296
|
```ruby
|
295
297
|
class MyCacheClient
|
@@ -351,10 +353,10 @@ params: INSPECTED_ARGUMENTS and options: INSPECTED_OPTIONS
|
|
351
353
|
|
352
354
|
```ruby
|
353
355
|
any_cache.write("data", 123, expires_in: 60)
|
354
|
-
# I, [2018-09-07T10:04:56.649960 #15761] INFO -- [AnyCache<AnyCache>/Activity<write>]: performed <write> operation with
|
356
|
+
# I, [2018-09-07T10:04:56.649960 #15761] INFO -- [AnyCache<AnyCache>/Activity<write>]: performed <write> operation with attributes: ["data", 123] and options: {:expires_in=>60}.
|
355
357
|
|
356
358
|
any_cache.clear
|
357
|
-
# I, [2018-09-07T10:05:26.999847 #15761] INFO -- [AnyCache<AnyCache>/Activity<clear>]: performed <clear> operation with
|
359
|
+
# I, [2018-09-07T10:05:26.999847 #15761] INFO -- [AnyCache<AnyCache>/Activity<clear>]: performed <clear> operation with attributes: [] and options: {}.
|
358
360
|
```
|
359
361
|
|
360
362
|
## Operations
|
@@ -380,6 +382,7 @@ any_cache.clear
|
|
380
382
|
- fetches data from the cache using the given key;
|
381
383
|
- if a `fallback` block has been passed and data with the given key does not exist - that block
|
382
384
|
will be called with the given key and the return value will be written to the cache;
|
385
|
+
- use `raw: true` if you want to fetch incrementable/decrementable entry;
|
383
386
|
|
384
387
|
```ruby
|
385
388
|
# --- entry exists ---
|
@@ -414,6 +417,7 @@ cache_store.fetch("data") # => nil
|
|
414
417
|
- get a set of entries in hash form from the cache storage using given keys;
|
415
418
|
- works in `#fetch` manner but with a series of entries;
|
416
419
|
- nonexistent entries will be fetched with `nil` values;
|
420
|
+
- use `raw: true` if you want to fetch incrementable/decrementable entries;
|
417
421
|
|
418
422
|
```ruby
|
419
423
|
# --- fetch entries ---
|
@@ -449,6 +453,7 @@ cache_store.fetch_multi("data", "second_data", "last_data", force: true) { |key|
|
|
449
453
|
### Read
|
450
454
|
|
451
455
|
- `AnyCache#read(key)` - get an entry value from the cache storage
|
456
|
+
- pass `raw: true` if you want to read incrementable/decrementable entries;
|
452
457
|
|
453
458
|
```ruby
|
454
459
|
# --- entry exists ---
|
@@ -456,6 +461,9 @@ cache_store.read("data") # => "some_data"
|
|
456
461
|
|
457
462
|
# --- entry doesnt exist ---
|
458
463
|
cache_store.read("data") # => nil
|
464
|
+
|
465
|
+
# --- read incrementable/decrementable entry ---
|
466
|
+
cache_store.read("data", raw: true) # => "2" (for example)
|
459
467
|
```
|
460
468
|
|
461
469
|
---
|
@@ -465,6 +473,7 @@ cache_store.read("data") # => nil
|
|
465
473
|
- `AnyCache#read_multi(*keys)`
|
466
474
|
- get entries from the cache storage in hash form;
|
467
475
|
- nonexistent entries will be fetched with `nil` values;
|
476
|
+
- pass `raw: true` if you want to read incrementable/decrementable entries;
|
468
477
|
|
469
478
|
```ruby
|
470
479
|
cache_store.read_multi("data", "another_data", "last_data", "super_data")
|
@@ -475,13 +484,22 @@ cache_store.read_multi("data", "another_data", "last_data", "super_data")
|
|
475
484
|
"last_data" => "some_data", # exisitng enry
|
476
485
|
"super_data" => nil # existing entry
|
477
486
|
}
|
487
|
+
|
488
|
+
# --- read incrementable/decrementable entries ---
|
489
|
+
cache_store.read_multi("data", "another_data", raw: true)
|
490
|
+
# => returns
|
491
|
+
{
|
492
|
+
"data" => "1",
|
493
|
+
"another_data" => "2",
|
494
|
+
}
|
478
495
|
```
|
479
496
|
|
480
497
|
---
|
481
498
|
|
482
499
|
### Write
|
483
500
|
|
484
|
-
- `AnyCache#write(key, value, [expires_in:])` - write a new entry to the cache storage
|
501
|
+
- `AnyCache#write(key, value, [expires_in:])` - write a new entry to the cache storage;
|
502
|
+
- pass `raw: true` if you want to store incrementable/decrementable entries;
|
485
503
|
|
486
504
|
```ruby
|
487
505
|
# --- permanent entry ---
|
@@ -489,23 +507,30 @@ cache_store.write("data", 123)
|
|
489
507
|
|
490
508
|
# --- temporal entry (expires in 60 seconds) ---
|
491
509
|
cache_store.write("data", 123, expires_in: 60)
|
510
|
+
|
511
|
+
# --- incrementable/decrementable entry ---
|
512
|
+
cache_store.write("data", 123, raw: true)
|
492
513
|
```
|
493
514
|
|
494
515
|
---
|
495
516
|
|
496
517
|
### Write Multi
|
497
518
|
|
498
|
-
- `AnyCache#write_multi(**entries)` - write a set of permanent entries to the cache storage
|
519
|
+
- `AnyCache#write_multi(**entries)` - write a set of permanent entries to the cache storage;
|
520
|
+
- pass `raw: true` if you want to store incrementable/decrementable entries;
|
499
521
|
|
500
522
|
```ruby
|
501
523
|
cache_store.write_multi("data" => "test", "another_data" => 123)
|
524
|
+
|
525
|
+
# --- incrementable/decrementable entries ---
|
526
|
+
cache_store.write_multi("data" => 1, "another_data" => 2, raw: true)
|
502
527
|
```
|
503
528
|
|
504
529
|
---
|
505
530
|
|
506
531
|
### Delete
|
507
532
|
|
508
|
-
- `AnyCache#delete(key)` - remove entry from the cache storage
|
533
|
+
- `AnyCache#delete(key)` - remove entry from the cache storage;
|
509
534
|
|
510
535
|
```ruby
|
511
536
|
cache_store.delete("data")
|
@@ -517,7 +542,7 @@ cache_store.delete("data")
|
|
517
542
|
|
518
543
|
- `AnyCache#delete_matched(pattern)`
|
519
544
|
- removes all entries with keys matching the pattern;
|
520
|
-
- currently unsupported: `:dalli`, `:as_mem_cache_store`, `:
|
545
|
+
- currently unsupported: `:dalli`, `:as_mem_cache_store`, `:as_dalli_store`;
|
521
546
|
|
522
547
|
```ruby
|
523
548
|
# --- using a regepx ---
|
@@ -532,11 +557,12 @@ cache_store.delete_matched("data")
|
|
532
557
|
### Increment
|
533
558
|
|
534
559
|
- `AnyCache#increment(key, amount = 1, [expires_in:])` - increment entry's value by the given amount
|
535
|
-
and set the new expiration time if needed
|
560
|
+
and set the new expiration time if needed;
|
561
|
+
- can increment only nonexistent entries OR entries that were written with `raw: true` option;
|
536
562
|
|
537
563
|
```ruby
|
538
564
|
# --- increment existing entry ---
|
539
|
-
cache_store.write("data", 1)
|
565
|
+
cache_store.write("data", 1, raw: true) # you must provide :raw => true for incrementable entries
|
540
566
|
|
541
567
|
# --- increment by default value (1) ---
|
542
568
|
cache_store.increment("data") # => 2
|
@@ -549,6 +575,9 @@ cache_store.incrmeent("data", expires_in: 31) # => 15
|
|
549
575
|
|
550
576
|
# --- increment nonexistent entry (create new entry) ---
|
551
577
|
cache_store.increment("another_data", 5, expires_in: 5) # => 5
|
578
|
+
|
579
|
+
# --- read incrementable entry ---
|
580
|
+
cache_store.read("data", raw: true) # you must provide :raw => true for incrementable entries
|
552
581
|
```
|
553
582
|
|
554
583
|
---
|
@@ -556,11 +585,12 @@ cache_store.increment("another_data", 5, expires_in: 5) # => 5
|
|
556
585
|
### Decrement
|
557
586
|
|
558
587
|
- `AnyCache#decrement(key, amount = 1, [expires_in:])` - decrement entry's value by the given amount
|
559
|
-
and set the new expiration time if needed
|
588
|
+
and set the new expiration time if needed;
|
589
|
+
- can decrement only nonexistent entries OR entries that were written with `raw: true` option;
|
560
590
|
|
561
591
|
```ruby
|
562
592
|
# --- decrement existing entry ---
|
563
|
-
cache_store.write("data", 15)
|
593
|
+
cache_store.write("data", 15, raw: true) # you must provide :raw => true for decrementable entries
|
564
594
|
|
565
595
|
# --- decrement by default value (1) ---
|
566
596
|
cache_store.decrement("data") # => 14
|
@@ -573,13 +603,16 @@ cache_store.decrememnt("data", expirs_in: 5) # => 3
|
|
573
603
|
|
574
604
|
# --- decrement nonexistent entry (create new entry) ---
|
575
605
|
cache_store.decrememnt("another_data", 2, expires_in: 10) # => -2 (or 0 for Dalli::Client)
|
606
|
+
|
607
|
+
# --- read decrementable entry ---
|
608
|
+
cache_store.read("data", raw: true) # you must provide :raw => true for decrementable entries
|
576
609
|
```
|
577
610
|
|
578
611
|
---
|
579
612
|
|
580
613
|
### Expire
|
581
614
|
|
582
|
-
- `AnyCache#expire(key, [expires_in:])` - expire entry immediately or set the new expiration time
|
615
|
+
- `AnyCache#expire(key, [expires_in:])` - expire entry immediately or set the new expiration time;
|
583
616
|
|
584
617
|
```ruby
|
585
618
|
# --- expire immediately ---
|
@@ -593,7 +626,7 @@ cache_store.expire("data", expires_in: 36)
|
|
593
626
|
|
594
627
|
### Persist
|
595
628
|
|
596
|
-
- `AnyCache#persist(key)` - change entry's expiration time to permanent
|
629
|
+
- `AnyCache#persist(key)` - change entry's expiration time to permanent;
|
597
630
|
|
598
631
|
```ruby
|
599
632
|
# --- create temporal entry (30 seconds) ---
|
@@ -607,7 +640,7 @@ cache_store.persist("data")
|
|
607
640
|
|
608
641
|
### Existence
|
609
642
|
|
610
|
-
- `AnyCache#exist?(key)` - determine if an entry exists
|
643
|
+
- `AnyCache#exist?(key)` - determine if an entry exists;
|
611
644
|
|
612
645
|
```ruby
|
613
646
|
# --- entry exists ---
|
@@ -621,7 +654,7 @@ cache_store.exist?("another-data") # => false
|
|
621
654
|
|
622
655
|
### Clear
|
623
656
|
|
624
|
-
- `AnyCache#clear()` - clear cache database
|
657
|
+
- `AnyCache#clear()` - clear cache database;
|
625
658
|
|
626
659
|
```ruby
|
627
660
|
# --- prepare cache data ---
|
@@ -640,6 +673,22 @@ cache_store.read("another_data") # => nil
|
|
640
673
|
|
641
674
|
---
|
642
675
|
|
676
|
+
### Cleanup
|
677
|
+
|
678
|
+
- `AnyCache#cleanup()` - remove expired entries from cache database
|
679
|
+
(make sense only for `:as_file_store` and `:as_memory_store` cache clients);
|
680
|
+
|
681
|
+
```ruby
|
682
|
+
# --- prepare cache data ---
|
683
|
+
cache_store.write("data", "123", expires_in: 5)
|
684
|
+
cache_store.write("another_data", "456", expires_in: 10)
|
685
|
+
|
686
|
+
# --- waiting for cache exiration (10 seconds) ---
|
687
|
+
cache_store.cleanup # remove expired entries from database (release disk space for example)
|
688
|
+
```
|
689
|
+
|
690
|
+
---
|
691
|
+
|
643
692
|
## Build
|
644
693
|
|
645
694
|
- see [bin/rspec](bin/rspec)
|
@@ -662,6 +711,7 @@ bin/rspec --test-as-memory-store # run specs with ActiveSupport::Cache::MemorySt
|
|
662
711
|
- instrumentation layer;
|
663
712
|
- global and configurable default expiration time;
|
664
713
|
- `#delete_matched` for memcached-based cache storages;
|
714
|
+
- rails integration;
|
665
715
|
|
666
716
|
---
|
667
717
|
|
data/any_cache.gemspec
CHANGED
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
require 'any_cache/version'
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
|
-
spec.required_ruby_version = '>= 2.3.
|
8
|
+
spec.required_ruby_version = '>= 2.3.8'
|
9
9
|
|
10
10
|
spec.name = 'any_cache'
|
11
11
|
spec.version = AnyCache::VERSION
|
@@ -28,11 +28,11 @@ Gem::Specification.new do |spec|
|
|
28
28
|
end
|
29
29
|
|
30
30
|
spec.add_dependency 'concurrent-ruby', '~> 1.0'
|
31
|
-
spec.add_dependency 'qonfig', '~> 0.
|
31
|
+
spec.add_dependency 'qonfig', '~> 0.8'
|
32
32
|
|
33
33
|
spec.add_development_dependency 'coveralls', '~> 0.8'
|
34
34
|
spec.add_development_dependency 'simplecov', '~> 0.16'
|
35
|
-
spec.add_development_dependency 'armitage-rubocop', '~> 0.
|
35
|
+
spec.add_development_dependency 'armitage-rubocop', '~> 0.13'
|
36
36
|
spec.add_development_dependency 'rspec', '~> 3.8'
|
37
37
|
|
38
38
|
spec.add_development_dependency 'bundler'
|
data/bin/rspec
CHANGED
@@ -56,7 +56,7 @@ module AnyCacheSpecRunner
|
|
56
56
|
) { run_as_memory_store_cache_specs! }
|
57
57
|
|
58
58
|
opts.on(
|
59
|
-
'--test-as-
|
59
|
+
'--test-as-memcache-store',
|
60
60
|
'Run specs with ActiveSupport::Cache::MemCacheStore cache storage'
|
61
61
|
) { run_as_mem_cache_store_cache_specs! }
|
62
62
|
|