方法
- #
- D
包含的模块
常量
MARK_COMPRESSED | = | "\x01".b.freeze |
MARK_UNCOMPRESSED | = | "\x00".b.freeze |
实例公共方法
_load(marked) 链接
来源: 显示 | 在 GitHub 上
# File activesupport/lib/active_support/cache/serializer_with_fallback.rb, line 88 def _load(marked) dumped = marked.byteslice(1..-1) dumped = Zlib::Inflate.inflate(dumped) if marked.start_with?(MARK_COMPRESSED) Cache::Entry.unpack(marshal_load(dumped)) end
dump(entry) 链接
来源: 显示 | 在 GitHub 上
# File activesupport/lib/active_support/cache/serializer_with_fallback.rb, line 73 def dump(entry) MARK_UNCOMPRESSED + Marshal.dump(entry.pack) end
dump_compressed(entry, threshold) 链接
来源: 显示 | 在 GitHub 上
# File activesupport/lib/active_support/cache/serializer_with_fallback.rb, line 77 def dump_compressed(entry, threshold) dumped = Marshal.dump(entry.pack) if dumped.bytesize >= threshold compressed = Zlib::Deflate.deflate(dumped) return MARK_COMPRESSED + compressed if compressed.bytesize < dumped.bytesize end MARK_UNCOMPRESSED + dumped end
dumped?(dumped) 链接
来源: 显示 | 在 GitHub 上
# File activesupport/lib/active_support/cache/serializer_with_fallback.rb, line 94 def dumped?(dumped) dumped.start_with?(MARK_UNCOMPRESSED, MARK_COMPRESSED) end