Sha256: ea99d73fea5756d1c4a06207c9083fe480b49bd0e3d95b5f013e6701f7cdbcd3

Contents?: true

Size: 663 Bytes

Versions: 9

Compression:

Stored size: 663 Bytes

Contents

# frozen_string_literal: true

module Paquito
  module CacheEntryCoder
    def self.dump(entry)
      attrs = [entry.value, entry.expires_at, entry.version]
      # drop any trailing nil values to save a couple bytes
      attrs.pop until !attrs.last.nil? || attrs.empty?
      attrs
    end

    def self.load(payload)
      entry = ::ActiveSupport::Cache::Entry.allocate
      value, expires_in, version = payload
      entry.instance_variable_set(:@value, value)
      entry.instance_variable_set(:@expires_in, expires_in)
      entry.instance_variable_set(:@created_at, 0.0)
      entry.instance_variable_set(:@version, version)
      entry
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
paquito-0.8.0 lib/paquito/cache_entry_coder.rb
paquito-0.7.0 lib/paquito/cache_entry_coder.rb
paquito-0.6.2 lib/paquito/cache_entry_coder.rb
paquito-0.6.1 lib/paquito/cache_entry_coder.rb
paquito-0.6.0 lib/paquito/cache_entry_coder.rb
paquito-0.5.0 lib/paquito/cache_entry_coder.rb
paquito-0.4.0 lib/paquito/cache_entry_coder.rb
paquito-0.3.1 lib/paquito/cache_entry_coder.rb
paquito-0.3.0 lib/paquito/cache_entry_coder.rb