Sha256: d9c44b4739239663d480d9b18c4f02ff57875f9c6d3d6e140f94cfa14bb2409f
Contents?: true
Size: 1.71 KB
Versions: 1
Compression:
Stored size: 1.71 KB
Contents
module ActiveSupport module Cache class MemcachedSnappyStore < Cache::MemCacheStore class UnsupportedOperation < StandardError; end def increment(*args) raise UnsupportedOperation.new("increment is not supported by: #{self.class.name}") end def decrement(*args) raise UnsupportedOperation.new("decrement is not supported by: #{self.class.name}") end protected def write_entry(key, entry, options) # normally unless_exist would make this method use add, add will not make sense on compressed entries raise UnsupportedOperation.new("unless_exist would try to use the unsupported add method") if options && options[:unless_exist] value = options[:raw] ? entry.value.to_s : entry expires_in = options[:expires_in].to_i if expires_in > 0 && !options[:raw] # Set the memcache expire a few minutes in the future to support race condition ttls on read expires_in += 5.minutes end serialized_value = Marshal.dump(value) serialized_compressed_value = Snappy.deflate(serialized_value) response = @data.set(escape_key(key), serialized_compressed_value, expires_in, true) response == Response::STORED rescue MemCache::MemCacheError => e logger.error("MemCacheError (#{e}): #{e.message}") if logger false end def deserialize_entry_with_snappy(*args) compressed_value = args.first decompressed_value = compressed_value.nil? ? compressed_value : Snappy.inflate(compressed_value) args[0] = decompressed_value deserialize_entry_without_snappy(*args) end alias_method_chain :deserialize_entry, :snappy end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
memcached_snappy_store-0.0.1 | lib/active_support/cache/memcached_snappy_store.rb |