Index Documentation

CacheTools
in package

FinalYes

Common cache actions.

DSN documentation:

CacheTools only handles the scheme part of the URL, the rest of the URL is described in the documentation of the parseDsn implementation of the respective backend.

The scheme can be a PHP classpath to an implementation of ICacheBackend, or any of these aliases:

  • array, null: maps to ArrayCache\ArrayCacheBackend or Index-Cache-ArrayCache-ArrayCacheBackend, uses a simple array backed cache that doesn't get saved.
  • memcached, memcache: maps to Memcached\MemcachedBackend or Index-Cache-Memcached-MemcachedBackend, provides a backend based on the memcached or memcache extension.
  • valkey, keydb, redis: maps to Valkey\ValkeyBackend or Index-Cache-Valkey-ValkeyBackend, provides a backend based on the phpredis extension.

Short names are currently hardcoded and cannot be expanded.

Table of Contents

Methods

backend()  : ICacheBackend
Retrieves cache provider based on DSN URL.
create()  : ICacheProvider
Uses a DSN URL to create a cache provider instance.
parse()  : ICacheProviderInfo
Parses a DSN URL.

Methods

backend()

Retrieves cache provider based on DSN URL.

public static backend(string $dsn) : ICacheBackend

Format of the DSN URLs are described in the documentation of the CacheTools class as a whole.

Parameters
$dsn : string

URL to create cache provider from.

Tags
throws
InvalidArgumentException

if $dsn is not a valid URL.

throws
RuntimeException

if no cache provider can be made using the URL.

Return values
ICacheBackend

Cache backend instance.

create()

Uses a DSN URL to create a cache provider instance.

public static create(string $dsn) : ICacheProvider

Format of the DSN URLs are described in the documentation of the CacheTools class as a whole.

Parameters
$dsn : string

URL to create cache provider from.

Tags
throws
InvalidArgumentException

if $dsn is not a valid URL.

throws
RuntimeException

if no cache provider can be made using the URL.

Return values
ICacheProvider

A cache provider.

parse()

Parses a DSN URL.

public static parse(string $dsn) : ICacheProviderInfo

Format of the DSN URLs are described in the documentation of the CacheTools class as a whole.

Parameters
$dsn : string

URL to create cache provider from.

Tags
throws
InvalidArgumentException

if $dsn is not a valid URL.

throws
RuntimeException

if no cache provider can be made using the URL.

Return values
ICacheProviderInfo

Cache provider info.


        
On this page

Search results