hudhaifas/silverstripe-remember

Reusable caching helper functions for SilverStripe using PSR-16 with Symfony Cache support

Installs: 44

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:silverstripe-vendormodule

dev-main / 1.x-dev 2025-05-01 02:35 UTC

This package is not auto-updated.

Last update: 2025-05-15 18:38:33 UTC


README

A lightweight SilverStripe module for caching expensive operations using remember(), remember_per_user(), and remember_once() helper functions.

Features

  • PSR-16 compatible (uses SilverStripe's built-in cache system)
  • Supports Symfony Cache (Redis, Filesystem, APCu, etc.)
  • Custom TTL per entry
  • Per-user and per-request caching
  • Easy global helpers

Configuration

By default, this module uses a dedicated cache pool named remembercache.

To make this work, you must define the remembercache service in your app config:

Option 1: Define or alias the remembercache pool

# Custom backend (e.g., Redis with namespace 'remember')
Psr\SimpleCache\CacheInterface.remembercache:
  factory: SilverStripe\Core\Cache\CacheFactory
  constructor:
    namespace: "remember"
    defaultLifetime: 86400
    backend: RedisCacheService

# OR alias to default backend
Psr\SimpleCache\CacheInterface.remembercache:
  alias: Psr\SimpleCache\CacheInterface.default

Option 2: Change which pool the module uses

Hudhaifas\CacheHelpers\Services\CacheHelperService:
  cache_name: Psr\SimpleCache\CacheInterface.default

This lets you route caching through any defined backend.