-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
79 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# frozen_string_literal: true | ||
|
||
# @api private | ||
# @since 0.4.0 | ||
module AnyCache::Dumper | ||
class << self | ||
# @param hash [Hash] | ||
# @return [Hash] | ||
# | ||
# @api private | ||
# @since 0.4.0 | ||
def transform_hash(hash) | ||
{}.tap do |entries| | ||
hash.each_pair do |key, value| | ||
entries[key] = dump(value) | ||
end | ||
end | ||
end | ||
|
||
# @param hash [Hash] | ||
# @return [Hash] | ||
# | ||
# @api private | ||
# @since 0.4.0 | ||
def detransform_hash(hash) | ||
{}.tap do |entries| | ||
hash.each_pair do |key, value| | ||
entries[key] = load(value) | ||
end | ||
end | ||
end | ||
|
||
# @param value [Object] | ||
# @return [String] | ||
# | ||
# @api private | ||
# @since 0.4.0 | ||
def dump(value) | ||
return value if value.nil? | ||
Zlib::Deflate.deflate(Marshal.dump(value)) | ||
end | ||
|
||
# @param value [String] | ||
# @return [Object] | ||
# | ||
# @api private | ||
# @since 0.4.0 | ||
def load(value) | ||
return value if value.nil? | ||
Marshal.load(Zlib::Inflate.inflate(value)) | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters