Skip to content

Commit 07b4e0f

Browse files
authored
Merge pull request #806 from demiankatz/flexible-key-pattern
Fix cache configuration for better Doctrine compatibility.
2 parents a63fb62 + f6b52c6 commit 07b4e0f

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/ConfigProvider.php

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -113,37 +113,36 @@ public function getValidatorConfig(): array
113113
}
114114

115115
/**
116-
* @return array<non-empty-string, array{adapter: string, options?: mixed[]}>
116+
* @return array<non-empty-string, array{adapter: string, options?: mixed[], plugins?: mixed[]}>
117117
*/
118118
public function getCachesConfig(): array
119119
{
120+
$defaultOptions = [
121+
'namespace' => 'DoctrineModule',
122+
'key_pattern' => '/^[a-z0-9_\+\-\[\]\\\\$]*$/Di',
123+
];
124+
120125
return [
121126
'doctrinemodule.cache.apcu' => [
122127
'adapter' => 'apcu',
123-
'options' => ['namespace' => 'DoctrineModule'],
128+
'options' => $defaultOptions,
124129
],
125130
'doctrinemodule.cache.array' => [
126131
'adapter' => Memory::class,
127-
'options' => ['namespace' => 'DoctrineModule'],
132+
'options' => $defaultOptions,
128133
],
129134
'doctrinemodule.cache.filesystem' => [
130135
'adapter' => 'filesystem',
131-
'options' => [
132-
'namespace' => 'DoctrineModule',
133-
'cache_dir' => 'data/DoctrineModule/cache',
134-
],
136+
'options' => $defaultOptions + ['cache_dir' => 'data/DoctrineModule/cache'],
137+
'plugins' => [['name' => 'serializer']],
135138
],
136139
'doctrinemodule.cache.memcached' => [
137140
'adapter' => 'memcached',
138-
'options' => [
139-
'namespace' => 'DoctrineModule',
140-
'servers' => [],
141-
],
141+
'options' => $defaultOptions + ['servers' => []],
142142
],
143143
'doctrinemodule.cache.redis' => [
144144
'adapter' => 'redis',
145-
'options' => [
146-
'namespace' => 'DoctrineModule',
145+
'options' => $defaultOptions + [
147146
'server' => [
148147
'host' => 'localhost',
149148
'post' => 6379,

0 commit comments

Comments
 (0)