Class/Module Index [+]

Quicksearch

ActiveSupport::Cache::Strategy::LocalCache

Constants

NULL

this allows caching of the fact that there is nothing in the remote cache

Public Instance Methods

clear() click to toggle source
# File lib/active_support/cache/strategy/local_cache.rb, line 88
def clear
  local_cache.clear if local_cache
  super
end
decrement(key, amount = 1) click to toggle source
# File lib/active_support/cache/strategy/local_cache.rb, line 79
def decrement(key, amount = 1)
  if value = super
    local_cache.mute { local_cache.write(key, value.to_s) } if local_cache
    value
  else
    nil
  end
end
delete(key, options = nil) click to toggle source
# File lib/active_support/cache/strategy/local_cache.rb, line 54
def delete(key, options = nil)
  local_cache.mute { local_cache.write(key, NULL) } if local_cache
  super
end
exist(key, options = nil) click to toggle source
# File lib/active_support/cache/strategy/local_cache.rb, line 59
def exist(key, options = nil)
  value = local_cache.read(key) if local_cache
  if value == NULL
    false
  elsif value
    true
  else
    super
  end
end
increment(key, amount = 1) click to toggle source
# File lib/active_support/cache/strategy/local_cache.rb, line 70
def increment(key, amount = 1)
  if value = super
    local_cache.mute { local_cache.write(key, value.to_s) } if local_cache
    value
  else
    nil
  end
end
middleware() click to toggle source
# File lib/active_support/cache/strategy/local_cache.rb, line 15
def middleware
  @middleware ||= begin
    klass = Class.new
    klass.class_eval(              def initialize(app)                @app = app              end              def call(env)                Thread.current[:#{thread_local_key}] = MemoryStore.new                @app.call(env)              ensure                Thread.current[:#{thread_local_key}] = nil              end, __FILE__, __LINE__ + 1)
    klass
  end
end
read(key, options = nil) click to toggle source
# File lib/active_support/cache/strategy/local_cache.rb, line 34
def read(key, options = nil)
  value = local_cache && local_cache.read(key)
  if value == NULL
    nil
  elsif value.nil?
    value = super
    local_cache.mute { local_cache.write(key, value || NULL) } if local_cache
    value.duplicable? ? value.dup : value
  else
    # forcing the value to be immutable
    value.duplicable? ? value.dup : value
  end
end
with_local_cache() click to toggle source
# File lib/active_support/cache/strategy/local_cache.rb, line 8
def with_local_cache
  Thread.current[thread_local_key] = MemoryStore.new
  yield
ensure
  Thread.current[thread_local_key] = nil
end
write(key, value, options = nil) click to toggle source
# File lib/active_support/cache/strategy/local_cache.rb, line 48
def write(key, value, options = nil)
  value = value.to_s if respond_to?(:raw?) && raw?(options)
  local_cache.mute { local_cache.write(key, value || NULL) } if local_cache
  super
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.