Module: ActiveSupport::Cache::Strategy::LocalCache

Included in:
MemCacheStore, NullStore, RedisCacheStore
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/cache/strategy/local_cache.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/cache/strategy/local_cache_middleware.rb

Overview

Caches that implement LocalCache will be backed by an in-memory cache for the duration of a block. Repeated calls to the cache for the same key will hit the in-memory cache for faster access.

Defined Under Namespace

Modules: LocalCacheRegistry Classes: LocalStore, Middleware

Instance Method Summary collapse

Instance Method Details

#cleanup(**options) ⇒ Object

:nodoc:



81
82
83
84
85
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/cache/strategy/local_cache.rb', line 81

def cleanup(**options) # :nodoc:
  return super unless cache = local_cache
  cache.clear
  super
end

#clear(**options) ⇒ Object

:nodoc:



75
76
77
78
79
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/cache/strategy/local_cache.rb', line 75

def clear(**options) # :nodoc:
  return super unless cache = local_cache
  cache.clear(options)
  super
end

#decrement(name, amount = 1, **options) ⇒ Object

:nodoc:



100
101
102
103
104
105
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/cache/strategy/local_cache.rb', line 100

def decrement(name, amount = 1, **options) # :nodoc:
  return super unless local_cache
  value = bypass_local_cache { super }
  write_cache_value(name, value, raw: true, **options)
  value
end

#delete_matched(matcher, options = nil) ⇒ Object

:nodoc:



87
88
89
90
91
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/cache/strategy/local_cache.rb', line 87

def delete_matched(matcher, options = nil) # :nodoc:
  return super unless cache = local_cache
  cache.clear
  super
end

#increment(name, amount = 1, **options) ⇒ Object

:nodoc:



93
94
95
96
97
98
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/cache/strategy/local_cache.rb', line 93

def increment(name, amount = 1, **options) # :nodoc:
  return super unless local_cache
  value = bypass_local_cache { super }
  write_cache_value(name, value, raw: true, **options)
  value
end

#middlewareObject

Middleware class can be inserted as a Rack handler to be local cache for the duration of request.



69
70
71
72
73
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/cache/strategy/local_cache.rb', line 69

def middleware
  @middleware ||= Middleware.new(
    "ActiveSupport::Cache::Strategy::LocalCache",
    local_cache_key)
end

#with_local_cache(&block) ⇒ Object

Use a local cache for the duration of block.



63
64
65
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/cache/strategy/local_cache.rb', line 63

def with_local_cache(&block)
  use_temporary_local_cache(LocalStore.new, &block)
end