檔案快取儲存庫
快取儲存庫實作,可將所有資料儲存在檔案系統中。
方法
常數
目錄格式化程式 | = | "%03X" |
檔名最大大小 | = | 226 |
檔案路徑最大大小 | = | 900 |
快取檔案 | = | [".gitkeep", ".keep"].freeze |
屬性
[R] | 快取路徑 |
類別公開方法
new(cache_path, **options) 連結
supports_cache_versioning?() 連結
公告支援快取版本控制。
執行個體公開方法
清理(options = nil) 連結
預先對所有已儲存金鑰進行迭代,並移除過期的金鑰。
清除(options = nil) 連結
從快取中刪除所有項目。在這種情況下,它會刪除,指定檔案儲存庫目錄中,除了 .keep 或 .gitkeep 以外的所有輸入。小心使用 FileStore
時,組態檔案中指定的目錄,因為目錄中的所有項目都會被刪除。
遞減(name, amount = 1, options = nil) 連結
遞減快取整數值。傳回更新後的數值。
若金鑰尚未設定,會將其設定為 -amount
。
cache.decrement("foo") # => -1
若要設定特定數值,請呼叫 write
cache.write("baz", 5)
cache.decrement("baz") # => 4
刪除配對(matcher, options = nil) 連結
# File activesupport/lib/active_support/cache/file_store.rb, line 89 def delete_matched(matcher, options = nil) options = merged_options(options) matcher = key_matcher(matcher, options) instrument(:delete_matched, matcher.inspect) do search_dir(cache_path) do |path| key = file_path_key(path) delete_entry(path, **options) if key.match(matcher) end end end
increment(名稱, 金額 = 1, 選項 = nil) 連結
增加快取整數數值。傳回更新後的數值。
如果沒有設定金鑰,則從 0
開始
cache.increment("foo") # => 1
cache.increment("bar", 100) # => 100
若要設定特定數值,請呼叫 write
cache.write("baz", 5)
cache.increment("baz") # => 6
來源:顯示 | 在 GitHub 上
# File activesupport/lib/active_support/cache/file_store.rb, line 60 def increment(name, amount = 1, options = nil) options = merged_options(options) key = normalize_key(name, options) instrument(:increment, key, amount: amount) do modify_value(name, amount, options) end end