Sha256: 0a7066bd265f5a807a61cb28522fbf97fb7189f3743242f6c31d111cd522de0d

Contents?: true

Size: 833 Bytes

Versions: 23

Compression:

Stored size: 833 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 < Para::ApplicationRecord
      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

      def mismatched?(_version = nil)
        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

23 entries across 23 versions & 1 rubygems

Version Path
para-0.12.5 app/models/para/cache/item.rb
para-0.12.4 app/models/para/cache/item.rb
para-0.12.3 app/models/para/cache/item.rb
para-0.12.2 app/models/para/cache/item.rb
para-0.12.1 app/models/para/cache/item.rb
para-0.12.0 app/models/para/cache/item.rb
para-0.11.4 app/models/para/cache/item.rb
para-0.11.3 app/models/para/cache/item.rb
para-0.11.2 app/models/para/cache/item.rb
para-0.11.1 app/models/para/cache/item.rb
para-0.11.0 app/models/para/cache/item.rb
para-0.10.0 app/models/para/cache/item.rb
para-0.9.4 app/models/para/cache/item.rb
para-0.9.3.3 app/models/para/cache/item.rb
para-0.9.3.2 app/models/para/cache/item.rb
para-0.9.3.1 app/models/para/cache/item.rb
para-0.9.2 app/models/para/cache/item.rb
para-0.9.0 app/models/para/cache/item.rb
para-0.8.15 app/models/para/cache/item.rb
para-0.8.14 app/models/para/cache/item.rb