Class: ActiveSupport::Cache::ActiveRecordStore::CacheItem

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/active_support/cache/active_record_store.rb

Overview

set database url:

ENV['ACTIVE_RECORD_CACHE_STORE_DATABASE_URL'] = "sqlite3://./db/test2.sqlite3"

Constant Summary collapse

DEFAULT_META_INFO =
{ :version => 0, :access_counter => 0 }

Instance Method Summary collapse

Instance Method Details

#debug_mode?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/active_support/cache/active_record_store.rb', line 23

def debug_mode?
  debug_mode
end

#expired?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/active_support/cache/active_record_store.rb', line 38

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

#valueObject



29
30
31
# File 'lib/active_support/cache/active_record_store.rb', line 29

def value
  Marshal.load(::Base64.decode64(self[:value])) if self[:value].present?
end

#value=(new_value) ⇒ Object



33
34
35
36
# File 'lib/active_support/cache/active_record_store.rb', line 33

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