0
A
回答
0
順便說一句,而不是將數據庫值存儲在文件中我會將它存儲在Redis中。
你會存儲在緩存文件數據庫實體是這樣的:
- _sCache_product_1
- _sCache_product_2
- _sCache_product_200
所以_sCache_producct_1店JSON編碼產品實體的值id爲1。所以當ID爲1的產品被刪除時,我知道我必須只刪除_sCache_product_1文件,而不是其他任何東西。你getProduct功能會是這樣的:
public function getProduct($id)
{
// First check the caching system if you have product with id
if ($product = $this->cache->readCache($id)) {
return json_decode($product, true);
}
// Product doesn't exist in cache fetch fetch it from the database
// then store it in the caching system.
}
這種方法是使用ORM像學說在這裏你可以創建事件偵聽器優雅的完成,但這是另一個話題。
相關問題
- 1. jquery緩存php ajax請求
- 2. typo3刪除fe插件的緩存與每個新的請求
- 3. Long PHP請求被刪除
- 4. PHP CURL刪除請求
- 5. 如何在PHP的JSON請求中製作緩存文件
- 6. Drupal刷新頁面需求緩存也刪除javascript文件
- 7. memcached緩存請求?
- 8. 緩存Tastypie請求
- 9. Hammock緩存請求?
- 10. 刪除特定URI的緩存文件
- 11. 刪除特定的緩存文件
- 12. 刪除舊AndroidStudio緩存文件夾 - OSX
- 13. Codeigniter緩存文件不會被刪除
- 14. iOS:如何刪除xib文件緩存?
- 15. phpthumb刪除特定文件的緩存
- 16. 從git緩存中刪除文件
- 17. asp.net緩存目標文件刪除
- 18. 使用PHP緩存Instagram API請求?
- 19. 用PHP緩存GET音頻請求
- 20. 刪除緩存
- 21. 是否可以從PHP APC緩存中刪除單個文件?
- 22. Foursquare刪除請求
- 23. Node.js刪除請求
- 24. 當應用程序被刪除時刪除緩存文件ios
- 25. PHP刪除從URL獲取請求
- 26. 執行一個php刪除請求
- 27. 從合併請求中刪除文件,但不是從git中刪除文件
- 28. 刪除緩存Wordpress
- 29. Mod_pagespeed刪除緩存?
- 30. Git刪除緩存