Sha256: 01c291988c22a7aeb85f7ecda0c9fb549aae90997d5f129544c5c02611e7eb90

Contents?: true

Size: 765 Bytes

Versions: 5

Compression:

Stored size: 765 Bytes

Contents

# Borrowed from activesupport-db-cache gem (https://github.com/sergio-fry/activesupport-db-cache),
# which is out of date now not allowing us to depend on it in para
#
module Para
  module Cache
    class Item < ActiveRecord::Base
      def value
        Marshal.load(::Base64.decode64(self[:value])) if self[:value].present?
      end

      def value=(new_value)
        @raw_value = new_value
        self[:value] = ::Base64.encode64(Marshal.dump(@raw_value))
      end

      def expired?
        read_attribute(:expires_at).try(:past?) || false
      end

      # From ActiveSupport::Cache::Store::Entry
      # Seconds since the epoch when the entry will expire.
      def expires_at
        read_attribute(:expires_at).try(:to_f)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
para-0.7.1 app/models/para/cache/item.rb
para-0.7.0 app/models/para/cache/item.rb
para-0.6.9 app/models/para/cache/item.rb
para-0.6.8 app/models/para/cache/item.rb
para-0.6.7 app/models/para/cache/item.rb