From 6888108a18385b4668cc41c3a0fbec67f12f6a07 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Sat, 7 Sep 2019 17:09:25 +0800 Subject: [PATCH] fix --- config/initializers/session_extenstions.rb | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 config/initializers/session_extenstions.rb diff --git a/config/initializers/session_extenstions.rb b/config/initializers/session_extenstions.rb new file mode 100644 index 000000000..cee3dfc06 --- /dev/null +++ b/config/initializers/session_extenstions.rb @@ -0,0 +1,33 @@ +#coding=utf-8 + +module SessionExtenstions + + module EntryExtension + def compressed? + @compressed + end + + def value + if @value + begin + Marshal.load(compressed? ? Zlib::Inflate.inflate(@value) : @value) + rescue TypeError + compressed? ? Zlib::Inflate.inflate(@value) : @value + end + end + end + + def size + if @value.nil? + 0 + else + @value.bytesize + end + end + end + + +end + +ActiveSupport::Cache::Entry.const_set("DEFAULT_COMPRESS_LIMIT", 1) +ActiveSupport::Cache::Entry.send(:prepend, SessionExtenstions::EntryExtension)