跳到內容 跳到搜尋

本機快取儲存體

簡單的記憶體後援快取。此快取未執行緒安全,且僅用作單一執行緒的臨時記憶體快取。

方法
C
D
N
R
W

類別公開方法

新建()

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

執行個體公開方法

清除(選項 = nil)

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

刪除項目(金鑰)

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

讀取項目(金鑰)

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

讀取多個項目(金鑰)

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

寫入項目(金鑰, 項目)

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