44
55module IdentityCache
66 module MemCacheStoreCAS
7+ Entry = ActiveSupport ::Cache ::Entry
8+
79 def cas ( name , options = nil )
810 options = merged_options ( options )
911 key = normalize_key ( name , options )
@@ -12,10 +14,10 @@ def cas(name, options = nil)
1214 instrument ( :cas , key , options ) do
1315 @data . with do |connection |
1416 connection . cas ( key , options [ :expires_in ] . to_i , options ) do |raw_value |
15- entry = deserialize_entry ( raw_value , raw : options [ :raw ] )
17+ entry = deserialize_entry ( raw_value , ** options )
1618 value = yield entry . value
17- entry = ActiveSupport :: Cache :: Entry . new ( value , **options )
18- options [ :raw ] ? entry . value . to_s : entry
19+ entry = Entry . new ( value , **options , version : normalize_version ( name , options ) )
20+ serialize_entry ( entry , ** options )
1921 end
2022 end
2123 end
@@ -34,7 +36,7 @@ def cas_multi(*names, **options)
3436
3537 values = { }
3638 raw_values . each do |key , raw_value |
37- entry = deserialize_entry ( raw_value . first , raw : options [ :raw ] )
39+ entry = deserialize_entry ( raw_value . first , ** options )
3840 values [ keys_to_names [ key ] ] = entry . value unless entry . expired?
3941 end
4042
@@ -43,21 +45,12 @@ def cas_multi(*names, **options)
4345 updates . each do |name , value |
4446 key = normalize_key ( name , options )
4547 cas_id = raw_values [ key ] . last
46- entry = ActiveSupport :: Cache :: Entry . new ( value , **options )
47- payload = options [ :raw ] ? entry . value . to_s : entry
48+ entry = Entry . new ( value , **options )
49+ payload = serialize_entry ( entry , ** options )
4850 @data . with { |c | c . replace_cas ( key , payload , cas_id , options [ :expires_in ] . to_i , options ) }
4951 end
5052 end
5153 end
5254 end
53-
54- if ActiveSupport ::Cache ::MemCacheStore . instance_method ( :deserialize_entry ) . arity == 1
55-
56- private
57-
58- def deserialize_entry ( payload , raw : nil )
59- super ( payload )
60- end
61- end
6255 end
6356end
0 commit comments