DoctrineDbalAdapter
extends AbstractAdapter
in package
implements
PruneableInterface
Table of Contents
Interfaces
- PruneableInterface
- Interface extends psr-6 and psr-16 caches to allow for pruning (deletion) of all expired cache items.
Constants
- MAX_KEY_LENGTH = 255
Properties
- $conn : Connection
- $dataCol : string
- $idCol : string
- $lifetimeCol : string
- $marshaller : MarshallerInterface
- $namespace : string
- $platformName : string
- $serverVersion : string
- $table : string
- $timeCol : string
Methods
- __construct() : mixed
- You can either pass an existing database Doctrine DBAL Connection or a DSN string that will be used to connect to the database.
- commit() : bool
- Persists any deferred cache items.
- configureSchema() : void
- createConnection() : mixed
- createSystemCache() : AdapterInterface
- Returns the best possible adapter that your runtime supports.
- createTable() : void
- Creates the table to store cache items which can be called once for setup.
- prune() : bool
- doClear() : bool
- doDelete() : bool
- doFetch() : iterable<string|int, mixed>
- doHave() : bool
- doSave() : array<string|int, mixed>|bool
- addTableToSchema() : void
- getPlatformName() : string
- getServerVersion() : string
Constants
MAX_KEY_LENGTH
private
mixed
MAX_KEY_LENGTH
= 255
Properties
$conn
private
Connection
$conn
$dataCol
private
string
$dataCol
= 'item_data'
$idCol
private
string
$idCol
= 'item_id'
$lifetimeCol
private
string
$lifetimeCol
= 'item_lifetime'
$marshaller
private
MarshallerInterface
$marshaller
$namespace
private
string
$namespace
$platformName
private
string
$platformName
$serverVersion
private
string
$serverVersion
$table
private
string
$table
= 'cache_items'
$timeCol
private
string
$timeCol
= 'item_time'
Methods
__construct()
You can either pass an existing database Doctrine DBAL Connection or a DSN string that will be used to connect to the database.
public
__construct(Connection|string $connOrDsn[, string $namespace = '' ][, int $defaultLifetime = 0 ][, array<string|int, mixed> $options = [] ][, MarshallerInterface|null $marshaller = null ]) : mixed
The cache table is created automatically when possible. Otherwise, use the createTable() method.
List of available options:
- db_table: The name of the table [default: cache_items]
- db_id_col: The column where to store the cache id [default: item_id]
- db_data_col: The column where to store the cache data [default: item_data]
- db_lifetime_col: The column where to store the lifetime [default: item_lifetime]
- db_time_col: The column where to store the timestamp [default: item_time]
Parameters
- $connOrDsn : Connection|string
- $namespace : string = ''
- $defaultLifetime : int = 0
- $options : array<string|int, mixed> = []
- $marshaller : MarshallerInterface|null = null
Tags
commit()
Persists any deferred cache items.
public
commit() : bool
Return values
bool —True if all not-yet-saved items were successfully saved or there were none. False otherwise.
configureSchema()
public
configureSchema(Schema $schema, Connection $forConnection) : void
Parameters
- $schema : Schema
- $forConnection : Connection
createConnection()
public
static createConnection(string $dsn[, array<string|int, mixed> $options = [] ]) : mixed
Parameters
- $dsn : string
- $options : array<string|int, mixed> = []
createSystemCache()
Returns the best possible adapter that your runtime supports.
public
static createSystemCache(string $namespace, int $defaultLifetime, string $version, string $directory[, LoggerInterface|null $logger = null ]) : AdapterInterface
Using ApcuAdapter makes system caches compatible with read-only filesystems.
Parameters
- $namespace : string
- $defaultLifetime : int
- $version : string
- $directory : string
- $logger : LoggerInterface|null = null
Return values
AdapterInterfacecreateTable()
Creates the table to store cache items which can be called once for setup.
public
createTable() : void
Cache ID are saved in a column of maximum length 255. Cache data is saved in a BLOB.
Tags
prune()
public
prune() : bool
Return values
booldoClear()
protected
doClear(string $namespace) : bool
Parameters
- $namespace : string
Return values
booldoDelete()
protected
doDelete(array<string|int, mixed> $ids) : bool
Parameters
- $ids : array<string|int, mixed>
Return values
booldoFetch()
protected
doFetch(array<string|int, mixed> $ids) : iterable<string|int, mixed>
Parameters
- $ids : array<string|int, mixed>
Return values
iterable<string|int, mixed>doHave()
protected
doHave(string $id) : bool
Parameters
- $id : string
Return values
booldoSave()
protected
doSave(array<string|int, mixed> $values, int $lifetime) : array<string|int, mixed>|bool
Parameters
- $values : array<string|int, mixed>
- $lifetime : int
Return values
array<string|int, mixed>|booladdTableToSchema()
private
addTableToSchema(Schema $schema) : void
Parameters
- $schema : Schema
getPlatformName()
private
getPlatformName() : string
Return values
stringgetServerVersion()
private
getServerVersion() : string