Class: RailsFastCache::Store

Inherits:
ActiveSupport::Cache::Store
  • Object
show all
Defined in:
lib/rails-fast-cache/store.rb

Class Method Summary collapse

Instance Method Summary collapse

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)
  options = parameters.extract_options!
  options[:compressor] ||= RailsFastCache::BrotliCompressor if !options.key?(:coder) && cache_store != :memory_store
  options[:serializer] ||= :message_pack unless options.key?(:coder)

  @cache_store = ActiveSupport::Cache.lookup_store(cache_store, *parameters, **options)
  @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

Returns:

  • (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_entryObject



71
72
73
# File 'lib/rails-fast-cache/store.rb', line 71

def read_serialized_entry(...)
  @cache_store.send(:read_serialized_entry, ...)
end

#shutdownObject



63
64
65
# File 'lib/rails-fast-cache/store.rb', line 63

def shutdown
  @scheduler.shutdown(wait: true)
end

#write_serialized_entryObject



67
68
69
# File 'lib/rails-fast-cache/store.rb', line 67

def write_serialized_entry(...)
  @cache_store.send(:write_serialized_entry, ...)
end