mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-03 03:40:49 +08:00
init project
This commit is contained in:
33
config/initializers/session_extenstions.rb
Normal file
33
config/initializers/session_extenstions.rb
Normal file
@@ -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)
|
||||
Reference in New Issue
Block a user