Class: Moneta::Adapters::LocalMemCache

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

Overview

LocalMemCache backend

Instance Method Summary collapse

Methods included from HashAdapter

#clear, #key?, #load, #store

Methods included from Defaults

#[], #[]=, #close, #decrement, #fetch, #increment, #key?

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

Raises:

  • (ArgumentError)


13
14
15
16
# File 'lib/moneta/adapters/localmemcache.rb', line 13

def initialize(options = {})
  raise ArgumentError, 'Option :file is required' unless options[:file]
  @hash = ::LocalMemCache.new(:filename => options[:file])
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 ‘Moneta::Transformer`)

  • :prefix (String)

    Prefix key (See ‘Moneta::Transformer`)

  • Other (Object)

    options as defined by the adapters or middleware

Returns:

  • (Object)

    current value



19
20
21
22
23
# File 'lib/moneta/adapters/localmemcache.rb', line 19

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