123456789_123456789_123456789_123456789_123456789_

Class: ActiveSupport::Cache::Strategy::LocalCache::LocalStore

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: ActiveSupport::Cache::Store
Defined in: activesupport/lib/active_support/cache/strategy/local_cache.rb

Overview

Simple memory backed cache. This cache is not thread safe and is intended only for serving as a temporary memory cache for a single thread.

Class Attribute Summary

Class Method Summary

::ActiveSupport::Cache::Store - Inherited

.new

Creates a new cache.

Instance Attribute Summary

Instance Method Summary

::ActiveSupport::Cache::Store - Inherited

#cleanup

Cleanups the cache by removing expired entries.

#clear

Clears the entire cache.

#decrement

Decrements an integer value in the cache.

#delete

Deletes an entry in the cache.

#delete_matched

Deletes all entries with keys matching the pattern.

#exist?

Returns true if the cache contains an entry for the given key.

#fetch

Fetches data from the cache, using the given key.

#fetch_multi

Fetches data from the cache, using the given keys.

#increment

Increments an integer value in the cache.

#mute

Silences the logger within a block.

#read

Reads data from the cache, using the given key.

#read_multi

Reads multiple values at once from the cache.

#silence,
#silence!

Silences the logger.

#write

Writes the value to the cache, with the key.

#write_multi

::ActiveSupport::Cache Storage API to write multiple values at once.

#key_matcher

Adds the namespace defined in the options to a pattern designed to match keys.

Constructor Details

.newLocalStore

[ GitHub ]

  
# File 'activesupport/lib/active_support/cache/strategy/local_cache.rb', line 39

def initialize
  super
  @data = {}
end

Instance Method Details

#clear(options = nil)

[ GitHub ]

  
# File 'activesupport/lib/active_support/cache/strategy/local_cache.rb', line 49

def clear(options = nil)
  @data.clear
end

#delete_entry(key, options)

[ GitHub ]

  
# File 'activesupport/lib/active_support/cache/strategy/local_cache.rb', line 73

def delete_entry(key, options)
  !!@data.delete(key)
end

#read_entry(key, options)

[ GitHub ]

  
# File 'activesupport/lib/active_support/cache/strategy/local_cache.rb', line 53

def read_entry(key, options)
  @data[key]
end

#read_multi_entries(keys, options)

[ GitHub ]

  
# File 'activesupport/lib/active_support/cache/strategy/local_cache.rb', line 57

def read_multi_entries(keys, options)
  values = {}

  keys.each do |name|
    entry = read_entry(name, options)
    values[name] = entry.value if entry
  end

  values
end

#write_entry(key, value, options)

[ GitHub ]

  
# File 'activesupport/lib/active_support/cache/strategy/local_cache.rb', line 68

def write_entry(key, value, options)
  @data[key] = value
  true
end