dalli-store-with-cas 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 95d123577ec7ed1f1772d433519a7f820dfcbd61
4
- data.tar.gz: 4c1921041a203af90a81acc92b167761df08da56
3
+ metadata.gz: 6c90a7113c8745572f38d25a7186104e7ad9ba45
4
+ data.tar.gz: 7c675fc318f2da8f868de22d76e5ee149128478c
5
5
  SHA512:
6
- metadata.gz: ab8e9c64d4998fdb44cbf46b488a9a24a9cbc18c4731a62b9b19089e6c3294f78c8549b9e1e47f456a6b7cfefc7f6251f6af482210a0bc909f18e0d078570e8c
7
- data.tar.gz: bb538ca70d1b096ff9ddf5f82e381fb7a9970b20ad7158de16761437b19814ae715c806af13acd4fe6090cd8442e4ac8ca598299f358997d0967e3bbda34c72e
6
+ metadata.gz: fe63dae8f1cbc7c40a2645c6611bc3b52a9e627510aaad65725d3c6cab8783243d73edefa8ff301d2f41f668bb20300275df7a00ff0aa617f792c1f4b370385c
7
+ data.tar.gz: 69c651e48a9d18d354ad4d5011864459f7497e8d6343a3c2df322b5e33f467e02194cd68d44dec6718a78424d1c4c2fcd46caf1d51dc5902ad286e582dac9881
@@ -4,7 +4,7 @@ require 'dalli/cas/client'
4
4
  module ActiveSupport
5
5
  module Cache
6
6
  class DalliStoreWithCas < DalliStore
7
- DALLI_STORE_WITH_CAS_VERSION = "0.0.2"
7
+ DALLI_STORE_WITH_CAS_VERSION = "0.0.3"
8
8
 
9
9
  def cas(name, options = {})
10
10
  cas_multi(name, options) { |kv| { kv.keys.first => yield(kv.values.first) } }
@@ -13,11 +13,18 @@ module ActiveSupport
13
13
  def cas_multi(*names, **options)
14
14
  return if names.empty?
15
15
 
16
- keys_to_names = Hash[names.map { |name| [namespaced_key(name, options), name] }]
16
+ namespaced_keys = names.map{|name| namespaced_key(name, options )}
17
+ using_single_cas = 1 == namespaced_keys.size
17
18
 
18
- instrument_with_log(:cas_multi, names, options) do
19
+
20
+ instrument_with_log((using_single_cas ? :cas : :cas_multi), names, options) do
19
21
  with do |c|
20
- keys_to_value_and_cas = c.get_multi_cas(keys_to_names.keys)
22
+ keys_to_value_and_cas = if using_single_cas
23
+ key_value, key_cas = c.get_cas(*namespaced_keys)
24
+ {namespaced_keys.first => [key_value, key_cas]} if key_value
25
+ else
26
+ c.get_multi_cas(*namespaced_keys)
27
+ end
21
28
 
22
29
  if keys_to_value_and_cas.present?
23
30
  values_to_yield = keys_to_value_and_cas.map do |key, value_and_cas|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dalli-store-with-cas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Misha Conway