Module: ActiveSupport::Cache::MongoCacheStore::Backend::Standard

Includes:
Base
Defined in:
lib/active_support/cache/mongo_cache_store/backend/standard.rb

Overview

Standard

Standard backend for MongoCacheStore

Description

Entreis are kept in a namespaced MongoDB collection. In a standard collection entries are only flushed from the collection with an explicit delete call or if auto_flush is enabled. If auto_flush is enabled the cache will flush all expired entries when auto_flush_threshold is reached. The threshold is based on a set number of cache instance writes.

Additional Options

The following options can be added to a MongoCacheStore constructor

options - Standard backend options

To see a list of core options see MongoCacheStore

:auto_flush - true | false

Default: true

If auto_flush is enabled the cache will flush all expired entries when auto_flush_threshold is reached.

:auto_flush_threshold - 10_000

Default: 10_000

A number representing the number of writes the when the cache should preform before flushing expired entries.

Instance Method Summary collapse

Methods included from Base

#decrement, #delete_matched, #increment, #read_multi

Instance Method Details

#clear(options = {}) ⇒ Object



43
44
45
46
47
48
49
50
# File 'lib/active_support/cache/mongo_cache_store/backend/standard.rb', line 43

def clear(options = {})
  col = get_collection(options) 
  ret = safe_rescue do
    col.remove
  end
  @collection = nil
  ret ? true : false
end