跳至内容 跳至搜索

本地缓存存储

简单的内存支持缓存。此缓存不是线程安全的,仅用于作为单个线程的临时内存缓存。

方法
C
D
N
R
W

类公共方法

new()

# File activesupport/lib/active_support/cache/strategy/local_cache.rb, line 36
def initialize
  @data = {}
end

实例公共方法

clear(options = nil)

# File activesupport/lib/active_support/cache/strategy/local_cache.rb, line 40
def clear(options = nil)
  @data.clear
end

delete_entry(key)

# File activesupport/lib/active_support/cache/strategy/local_cache.rb, line 57
def delete_entry(key)
  !!@data.delete(key)
end

read_entry(key)

# File activesupport/lib/active_support/cache/strategy/local_cache.rb, line 44
def read_entry(key)
  @data[key]
end

read_multi_entries(keys)

# File activesupport/lib/active_support/cache/strategy/local_cache.rb, line 48
def read_multi_entries(keys)
  @data.slice(*keys)
end

write_entry(key, entry)

# File activesupport/lib/active_support/cache/strategy/local_cache.rb, line 52
def write_entry(key, entry)
  @data[key] = entry
  true
end