toastnz/dbcache

DataObject-based cache for SilverStripe

Installs: 603

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 3

Forks: 0

Open Issues: 0

Type: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

DataObject-based cache for SilverStripe.

Requirements

  • SilverStripe 4

Installation

composer require toastnz/dbcache

Set the default expiry time in minutes for cache entries

Toast\DBCache\Helpers\DBCache:
  expiry_minutes: 0

Whether to clear all cached data when ?flush is invoked

Toast\DBCache\Extensions\ControllerDBCacheExtension:
  clear_on_flush: true

Manipulate cache entries

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