2008-05-18 06:22:34 +02:00
|
|
|
module ActiveSupport
|
|
|
|
module Cache
|
|
|
|
class CompressedMemCacheStore < MemCacheStore
|
2008-09-07 07:54:05 +02:00
|
|
|
def read(name, options = nil)
|
|
|
|
if value = super(name, (options || {}).merge(:raw => true))
|
2008-10-27 07:47:01 +01:00
|
|
|
if raw?(options)
|
|
|
|
value
|
|
|
|
else
|
|
|
|
Marshal.load(ActiveSupport::Gzip.decompress(value))
|
|
|
|
end
|
2008-05-18 06:22:34 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2008-09-07 07:54:05 +02:00
|
|
|
def write(name, value, options = nil)
|
2008-10-27 07:47:01 +01:00
|
|
|
value = ActiveSupport::Gzip.compress(Marshal.dump(value)) unless raw?(options)
|
|
|
|
super(name, value, (options || {}).merge(:raw => true))
|
2008-05-18 06:22:34 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|