Class: CodeToQuery::Performance::Cache::RailsCacheAdapter
- Inherits:
-
Object
- Object
- CodeToQuery::Performance::Cache::RailsCacheAdapter
- Defined in:
- lib/code_to_query/performance/cache.rb
Overview
Adapter for Rails cache
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #clear ⇒ Object
- #delete(key) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(rails_cache) ⇒ RailsCacheAdapter
constructor
A new instance of RailsCacheAdapter.
- #size ⇒ Object
Constructor Details
#initialize(rails_cache) ⇒ RailsCacheAdapter
Returns a new instance of RailsCacheAdapter.
164 165 166 |
# File 'lib/code_to_query/performance/cache.rb', line 164 def initialize(rails_cache) @rails_cache = rails_cache end |
Instance Method Details
#[](key) ⇒ Object
168 169 170 |
# File 'lib/code_to_query/performance/cache.rb', line 168 def [](key) @rails_cache.read(key) end |
#[]=(key, value) ⇒ Object
172 173 174 |
# File 'lib/code_to_query/performance/cache.rb', line 172 def []=(key, value) @rails_cache.write(key, value, expires_in: 3600) # 1 hour end |
#clear ⇒ Object
180 181 182 |
# File 'lib/code_to_query/performance/cache.rb', line 180 def clear @rails_cache.clear end |
#delete(key) ⇒ Object
176 177 178 |
# File 'lib/code_to_query/performance/cache.rb', line 176 def delete(key) @rails_cache.delete(key) end |
#each(&block) ⇒ Object
189 190 191 192 |
# File 'lib/code_to_query/performance/cache.rb', line 189 def each(&block) # Rails cache doesn't support iteration # This limits our LRU eviction capability with Rails cache end |
#size ⇒ Object
184 185 186 187 |
# File 'lib/code_to_query/performance/cache.rb', line 184 def size # Rails cache doesn't expose size easily 0 end |