Class: RailsFastCache::Store
- Inherits:
-
ActiveSupport::Cache::Store
- Object
- ActiveSupport::Cache::Store
- RailsFastCache::Store
- Defined in:
- lib/rails-fast-cache/store.rb
Class Method Summary collapse
Instance Method Summary collapse
- #flush(timeout = nil) ⇒ Object
-
#initialize(cache_store, *parameters) ⇒ Store
constructor
A new instance of Store.
- #read_serialized_entry ⇒ Object
- #shutdown ⇒ Object
- #write_serialized_entry ⇒ Object
Constructor Details
#initialize(cache_store, *parameters) ⇒ Store
Returns a new instance of Store.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/rails-fast-cache/store.rb', line 44 def initialize(cache_store, *parameters) = parameters. [:compressor] ||= RailsFastCache::BrotliCompressor if !.key?(:coder) && cache_store != :memory_store [:serializer] ||= :message_pack unless .key?(:coder) @cache_store = ActiveSupport::Cache.lookup_store(cache_store, *parameters, **) @scheduler = RailsFastCache::Scheduler.new unless @cache_store.singleton_class.include?(RailsFastCache::AsyncWrites) @cache_store.singleton_class.prepend(RailsFastCache::AsyncWrites) end @cache_store.rails_fast_cache_scheduler = @scheduler @cache_store.rails_fast_cache_logger = @cache_store.logger end |
Class Method Details
.supports_cache_versioning? ⇒ Boolean
40 41 42 |
# File 'lib/rails-fast-cache/store.rb', line 40 def self.supports_cache_versioning? true end |
Instance Method Details
#flush(timeout = nil) ⇒ Object
59 60 61 |
# File 'lib/rails-fast-cache/store.rb', line 59 def flush(timeout = nil) @scheduler.flush(timeout) end |
#read_serialized_entry ⇒ Object
71 72 73 |
# File 'lib/rails-fast-cache/store.rb', line 71 def read_serialized_entry(...) @cache_store.send(:read_serialized_entry, ...) end |
#shutdown ⇒ Object
63 64 65 |
# File 'lib/rails-fast-cache/store.rb', line 63 def shutdown @scheduler.shutdown(wait: true) end |
#write_serialized_entry ⇒ Object
67 68 69 |
# File 'lib/rails-fast-cache/store.rb', line 67 def write_serialized_entry(...) @cache_store.send(:write_serialized_entry, ...) end |