1
我正在尋找以下緩存行爲,與緩存標記非常相似,但帶有扭曲。如何獲取標記有快速訪問關鍵字的緩存記錄?
讓我們假裝有一種叫做keywords()
的緩存方法。請看下面的代碼:
Cache::keywords(['user', 'general'])->put('key1', $value1, $minutes);
Cache::keywords('general')->put('key2', $value2, $minutes2);
這將在key1
和$value2
存儲$value1
在key2
,他們是通過其相應的關鍵字都「標記」。
現在這裏是與緩存標籤的區別:關鍵字沒有排序或限制任何下面的流利調用。例如:
// Fetches value of key1, keywords are NOT required.
Cache::get('key1');
// Fetches value of key2, keywords are NOT required.
Cache::get('key2');
// Deletes all records using this keyword, viz. key1.
// key1 is completely out of cache storage, despite its other keyword.
Cache::keywords('user')->flush();
// Deletes all records using this keyword, viz. key1 and key2.
// key1 is completely out of cache storage, despite its other keyword.
Cache::keywords('general')->flush();
這是Laravel開箱即用的可能性嗎?
如果不是這樣,那麼如何處理這個問題,以便它對所有緩存驅動程序都是通用的?