Skip to content

Commit a7494f6

Browse files
committed
Addressed feedback
1 parent b67a05a commit a7494f6

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/Symfony/Component/Cache/Adapter/PdoTagAwareAdapter.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,20 @@
2222
class PdoTagAwareAdapter extends AbstractTagAwareAdapter implements PruneableInterface
2323
{
2424
use PdoTrait {
25-
doSave as public doSaveItem;
26-
prune as public pruneItems;
25+
doSave as private doSaveItem;
26+
prune as private pruneItems;
2727
}
2828

2929
/**
3030
* No need for a prefix here, should improve lookup time.
3131
*/
3232
protected const TAGS_PREFIX = '';
3333

34+
private string $tagsTable = 'cache_tags';
35+
private string $tagCol = 'item_tag';
36+
private string $tagIdxName = 'idx_cache_tags_item_tag';
37+
38+
3439
/**
3540
* You can either pass an existing database connection as PDO instance or
3641
* a DSN string that will be used to lazy-connect to the database when the
@@ -71,10 +76,10 @@ private function createTagsTable(): void
7176
// - trailing space removal
7277
// - case-insensitivity
7378
// - language processing like é == e
74-
'mysql' => "CREATE TABLE $this->tagsTable ($this->idCol VARBINARY(255) NOT NULL, $this->tagCol VARBINARY(255) NOT NULL, PRIMARY KEY($this->idCol, $this->tagCol), INDEX idx_id_col ($this->idCol), INDEX idx_tag_col ($this->tagCol)) COLLATE utf8mb4_bin, ENGINE = InnoDB",
75-
'sqlite' => "CREATE TABLE $this->tagsTable ($this->idCol TEXT NOT NULL, $this->tagCol TEXT NOT NULL, PRIMARY KEY ($this->idCol, $this->tagCol));CREATE INDEX idx_id_col ON $this->tagsTable($this->idCol);CREATE INDEX idx_tag_col ON $this->tagsTable($this->tagCol)",
76-
'pgsql', 'sqlsrv' => "CREATE TABLE $this->tagsTable ($this->idCol VARCHAR(255) NOT NULL, $this->tagCol VARCHAR(255) NOT NULL, PRIMARY KEY($this->idCol, $this->tagCol);CREATE INDEX idx_id_col ON $this->tagsTable($this->idCol);CREATE INDEX idx_tag_col ON $this->tagsTable($this->tagCol)",
77-
'oci' => "CREATE TABLE $this->tagsTable ($this->idCol VARCHAR2(255) NOT NULL, $this->tagCol VARCHAR2(255) NOT NULL, PRIMARY KEY($this->idCol, $this->tagCol);CREATE INDEX idx_id_col ON $this->tagsTable($this->idCol);CREATE INDEX idx_tag_col ON $this->tagsTable($this->tagCol)",
79+
'mysql' => "CREATE TABLE $this->tagsTable ($this->idCol VARBINARY(255) NOT NULL, $this->tagCol VARBINARY(255) NOT NULL, PRIMARY KEY($this->idCol, $this->tagCol), INDEX $this->tagIdxName($this->tagCol)) COLLATE utf8mb4_bin, ENGINE = InnoDB",
80+
'sqlite' => "CREATE TABLE $this->tagsTable ($this->idCol TEXT NOT NULL, $this->tagCol TEXT NOT NULL, PRIMARY KEY ($this->idCol, $this->tagCol));CREATE INDEX $this->tagIdxName ON $this->tagsTable($this->tagCol)",
81+
'pgsql', 'sqlsrv' => "CREATE TABLE $this->tagsTable ($this->idCol VARCHAR(255) NOT NULL, $this->tagCol VARCHAR(255) NOT NULL, PRIMARY KEY($this->idCol, $this->tagCol);CREATE INDEX $this->tagIdxName ON $this->tagsTable($this->tagCol)",
82+
'oci' => "CREATE TABLE $this->tagsTable ($this->idCol VARCHAR2(255) NOT NULL, $this->tagCol VARCHAR2(255) NOT NULL, PRIMARY KEY($this->idCol, $this->tagCol);CREATE INDEX $this->tagIdxName ON $this->tagsTable($this->tagCol)",
7883
default => throw new \DomainException(\sprintf('Creating the cache table is currently not implemented for PDO driver "%s".', $driver)),
7984
};
8085

src/Symfony/Component/Cache/Traits/PdoTrait.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,10 @@ trait PdoTrait
3030
private string $driver;
3131
private string $serverVersion;
3232
private string $table = 'cache_items';
33-
private string $tagsTable = 'cache_tags';
3433
private string $idCol = 'item_id';
3534
private string $dataCol = 'item_data';
3635
private string $lifetimeCol = 'item_lifetime';
3736
private string $timeCol = 'item_time';
38-
private string $tagCol = 'item_tag';
3937
private ?string $username = null;
4038
private ?string $password = null;
4139
private array $connectionOptions = [];

0 commit comments

Comments
 (0)