1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #22202 from grosser/grosser/write-consistent

even if a write fails, store the raw value
This commit is contained in:
Arthur Nogueira Neves 2015-12-05 15:57:19 -05:00
commit edc3deb9f1
2 changed files with 12 additions and 4 deletions

View file

@ -36,13 +36,13 @@ module ActiveSupport
end
def write_entry(key, entry, options) # :nodoc:
retval = super
if options[:raw] && local_cache && retval
if options[:raw] && local_cache
raw_entry = Entry.new(entry.value.to_s)
raw_entry.expires_at = entry.expires_at
local_cache.write_entry(key, raw_entry, options)
super(key, raw_entry, options)
else
super
end
retval
end
end

View file

@ -655,6 +655,14 @@ module LocalCacheBehavior
end
end
def test_local_cache_of_read_nil
@cache.with_local_cache do
assert_equal nil, @cache.read('foo')
@cache.send(:bypass_local_cache) { @cache.write 'foo', 'bar' }
assert_equal nil, @cache.read('foo')
end
end
def test_local_cache_of_delete
@cache.with_local_cache do
@cache.write('foo', 'bar')