toastnz / dbcache
SilverStripe 的基于 DataObject 的缓存
1.0.1
2022-12-16 02:29 UTC
Requires
- silverstripe/framework: ~4.0
- silverstripe/vendor-plugin: ^1.0
README
SilverStripe 的基于 DataObject 的缓存。
要求
- SilverStripe 4
安装
composer require toastnz/dbcache
设置缓存条目的默认过期时间(分钟)
Toast\DBCache\Helpers\DBCache: expiry_minutes: 0
当调用 ?flush 时是否清除所有缓存数据
Toast\DBCache\Extensions\ControllerDBCacheExtension: clear_on_flush: true
操作缓存条目
// Cache "filters" for 10 minutes under the namespace "product" DBCache::set('product.filters', json_encode($products), 10); // Retrieve from cache DBCache::get('product.filters'); // Remove from cache DBCache::clear('product.filters'); // Flush cached data for the "product" namespace DBCache::flush('product'); // Flush all cached data DBCache::flush();