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.



45
46
47
48
49
50
51
52
# File 'lib/rails-fast-cache/store.rb', line 45

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)
  self.class.cache_store = @cache_store
end

Class Method Details

.shutdownObject



41
42
43
# File 'lib/rails-fast-cache/store.rb', line 41

def self.shutdown
  RailsFastCache::Scheduler.shutdown
end

.supports_cache_versioning?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/rails-fast-cache/store.rb', line 37

def self.supports_cache_versioning?
  true
end

Instance Method Details

#shutdownObject



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

def shutdown
  self.class.shutdown
end

#write(name, value, options = nil) ⇒ Object



54
55
56
57
# File 'lib/rails-fast-cache/store.rb', line 54

def write(name, value, options = nil)
  WriteJob.perform_later(@cache_store, name, value, options)
  true
end

#write_multi(hash, options = nil) ⇒ Object



59
60
61
62
# File 'lib/rails-fast-cache/store.rb', line 59

def write_multi(hash, options = nil)
  WriteMultiJob.perform_later(@cache_store, hash, options)
  true
end