$sql =
match ($this->driver
) { // We use varbinary for the ID column because it prevents unwanted conversions:
// - character set conversions between server and client
// - trailing space removal
// - case-insensitivity
// - language processing like é == e
'mysql' => "CREATE TABLE
$this->table (
$this->idCol VARBINARY(255) NOT NULL PRIMARY KEY,
$this->dataCol MEDIUMBLOB NOT NULL,
$this->lifetimeCol INTEGER UNSIGNED,
$this->timeCol INTEGER UNSIGNED NOT NULL) COLLATE utf8mb4_bin, ENGINE = InnoDB",
'sqlite' => "CREATE TABLE
$this->table (
$this->idCol TEXT NOT NULL PRIMARY KEY,
$this->dataCol BLOB NOT NULL,
$this->lifetimeCol INTEGER,
$this->timeCol INTEGER NOT NULL)",
'pgsql' => "CREATE TABLE
$this->table (
$this->idCol VARCHAR(255) NOT NULL PRIMARY KEY,
$this->dataCol BYTEA NOT NULL,
$this->lifetimeCol INTEGER,
$this->timeCol INTEGER NOT NULL)",
'oci' => "CREATE TABLE
$this->table (
$this->idCol VARCHAR2(255) NOT NULL PRIMARY KEY,
$this->dataCol BLOB NOT NULL,
$this->lifetimeCol INTEGER,
$this->timeCol INTEGER NOT NULL)",
'sqlsrv' => "CREATE TABLE
$this->table (
$this->idCol VARCHAR(255) NOT NULL PRIMARY KEY,
$this->dataCol VARBINARY(MAX) NOT NULL,
$this->lifetimeCol INTEGER,
$this->timeCol INTEGER NOT NULL)",
default =>
throw new \
DomainException(sprintf('Creating the cache table is currently not implemented for PDO driver "%s".',
$this->driver
)),
};
$conn->
exec($sql);
} public function prune(): bool
{ $deleteSql = "DELETE FROM
$this->table WHERE
$this->lifetimeCol +
$this->timeCol <= :time";
if ('' !==
$this->namespace
) { $deleteSql .= " AND
$this->idCol LIKE :namespace";
}