25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/identity_cache/mem_cache_store_cas.rb', line 25
def cas_multi(*names, **options)
return if names.empty?
options = merged_options(options)
keys_to_names = names.each_with_object({}) { |name, hash| hash[normalize_key(name, options)] = name }
keys = keys_to_names.keys
rescue_error_with(false) do
instrument(:cas_multi, keys, options) do
raw_values = @data.with { |c| c.get_multi_cas(keys) }
values = {}
raw_values.each do |key, raw_value|
entry = deserialize_entry(raw_value.first, raw: options[:raw])
values[keys_to_names[key]] = entry.value unless entry.expired?
end
updates = yield values
updates.each do |name, value|
key = normalize_key(name, options)
cas_id = raw_values[key].last
entry = ActiveSupport::Cache::Entry.new(value, **options)
payload = options[:raw] ? entry.value.to_s : entry
@data.with { |c| c.replace_cas(key, payload, cas_id, options[:expires_in].to_i, options) }
end
end
end
end
|