mrcr-cache 0.1.3 → 0.1.4
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/README.md +1 -1
- data/lib/mrcr/cache.rb +4 -8
- data/lib/mrcr/cache/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d8ac8ff74107302655d943ee533b14e13b80ca82
|
|
4
|
+
data.tar.gz: b0a100b970e79b8894bef170a1c76eed121efb7b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 32a037fe6f66ace14eb7c9a7ea1a637081d540d1e9da55aef3d84d3026267830d5b801fa8ce5acd537fd0c50563d391aba95968791f5147e1192296cb695e4a6
|
|
7
|
+
data.tar.gz: b9c5d2d059e056092dcd3e1dd2872f49ed3362b5ef51effcc910c51523c7ed4720951dcaed1e64fa88339c47f69b1c48505537399e05c963576126000163ab9a
|
data/README.md
CHANGED
|
@@ -36,7 +36,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
|
36
36
|
## Thanks
|
|
37
37
|
|
|
38
38
|
- This project is a copy of cache module from https://github.com/dry-rb/dry-core.
|
|
39
|
-
|
|
39
|
+
Extracted for better support for our own needs(fetch feature), as it primary uses only `concurrent-ruby`.
|
|
40
40
|
|
|
41
41
|
## Contributing
|
|
42
42
|
|
data/lib/mrcr/cache.rb
CHANGED
|
@@ -50,17 +50,14 @@ module Mrcr
|
|
|
50
50
|
cache.fetch_or_store(key.hash, &block)
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
-
#
|
|
53
|
+
# Fetch a cache by key & default
|
|
54
54
|
#
|
|
55
55
|
# @param [Object] key Hashable object
|
|
56
56
|
# @param [Object] default Default value
|
|
57
|
-
# @yield An arbitrary block
|
|
58
57
|
#
|
|
59
|
-
# @note
|
|
60
|
-
# this means you shouldn't pass Procs in args unless you're sure
|
|
61
|
-
# they are always the same instances, otherwise you introduce a memory leak
|
|
58
|
+
# @note (see #fetch_or_store)
|
|
62
59
|
#
|
|
63
|
-
# @return [Object]
|
|
60
|
+
# @return [Object] return value or default
|
|
64
61
|
def fetch(key, default = nil)
|
|
65
62
|
cache.fetch(key.hash, default)
|
|
66
63
|
end
|
|
@@ -81,9 +78,8 @@ module Mrcr
|
|
|
81
78
|
#
|
|
82
79
|
# @param [Object] key Hashable object
|
|
83
80
|
# @param [Object] default Default value.
|
|
84
|
-
# @yield An arbitrary block
|
|
85
81
|
#
|
|
86
|
-
# @return [Object]
|
|
82
|
+
# @return [Object] return value or default
|
|
87
83
|
def fetch(key, default = nil)
|
|
88
84
|
self.class.fetch(key, default)
|
|
89
85
|
end
|
data/lib/mrcr/cache/version.rb
CHANGED