Class: Moneta::Adapters::LocalMemCache

Inherits:
Object
  • Object
show all
Includes:
Defaults, HashAdapter
Defined in:
lib/moneta/adapters/localmemcache.rb

Overview

LocalMemCache backend

Instance Attribute Summary

Attributes included from HashAdapter

#backend

Instance Method Summary collapse

Methods included from HashAdapter

#clear, #fetch_values, #key?, #load, #merge!, #slice, #store, #values_at

Methods included from Defaults

#[], #[]=, #close, #create, #decrement, #each_key, #features, #fetch, #fetch_values, included, #increment, #key?, #merge!, #slice, #supports?, #update, #values_at

Methods included from OptionSupport

#expires, #prefix, #raw, #with

Constructor Details

#initialize(options = {}) ⇒ LocalMemCache

Returns a new instance of LocalMemCache

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :file (String)

    Database file

  • :backend (::LocalMemCache)

    Use existing backend instance


14
15
16
17
18
19
20
# File 'lib/moneta/adapters/localmemcache.rb', line 14

def initialize(options = {})
  @backend = options[:backend] ||
    begin
      raise ArgumentError, 'Option :file is required' unless options[:file]
      ::LocalMemCache.new(filename: options[:file])
    end
end

Instance Method Details

#delete(key, options = {}) ⇒ Object

Delete the key from the store and return the current value

Parameters:

  • key (Object)
  • options (Hash) (defaults to: {})

Options Hash (options):

  • :raw (Boolean)

    Raw access without value transformation (See Transformer)

  • :prefix (String)

    Prefix key (See Transformer)

  • Other (Object)

    options as defined by the adapters or middleware

Returns:

  • (Object)

    current value


23
24
25
26
27
# File 'lib/moneta/adapters/localmemcache.rb', line 23

def delete(key, options = {})
  value = load(key, options)
  @backend.delete(key)
  value
end