toastnz/dbcache

SilverStripe 的基于 DataObject 的缓存

安装次数: 579

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 3

分支: 0

开放问题: 0

类型:silverstripe-vendormodule

1.0.1 2022-12-16 02:29 UTC

This package is auto-updated.

Last update: 2024-09-16 06:21:09 UTC


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();