PHP code example of moselwal / keyvalue-store
1. Go to this page and download the library: Download moselwal/keyvalue-store library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
moselwal / keyvalue-store example snippets
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['pages'] = [
'backend' => \Moselwal\KeyValueStore\Cache\Backend\KeyValueBackend::class,
'options' => [
'hostname' => 'valkey.internal',
'port' => 6379,
'database' => 3,
'password' => 'secret',
'persistentConnection' => true,
'defaultLifetime' => 2592000,
'compression' => true,
// TLS / mTLS (optional)
'tls' => true,
'ca_file' => '/run/tls/ca.crt',
'cert_file' => '/run/tls/httpd.crt',
'key_file' => '/run/tls/httpd.key',
'peer_name' => 'valkey.internal',
'verify_peer' => true,
'verify_peer_name' => true,
// Sentinel (optional)
'sentinel' => true,
'sentinel_host' => 'sentinel.internal',
'sentinel_port' => 26379,
'sentinel_service' => 'mymaster',
// phpredis 6.x backoff (optional)
'backoff' => [
'algorithm' => \Redis::BACKOFF_ALGORITHM_DECORRELATED_JITTER,
'base' => 500,
'cap' => 750,
],
],
];
$GLOBALS['TYPO3_CONF_VARS']['SYS']['session']['BE'] = [
'backend' => \Moselwal\KeyValueStore\Session\Backend\KeyValueSessionBackend::class,
'options' => [
'hostname' => 'valkey.internal',
'database' => 1,
'password' => 'secret',
'persistentConnection' => true,
'persistentId' => 'typo3-session-be',
'prefix' => 'typo3:sess:be:',
'sessionLifetime' => 3600,
// TLS / Sentinel options as above
],
];
$GLOBALS['TYPO3_CONF_VARS']['SYS']['locking']['strategies'][
\Moselwal\KeyValueStore\Locking\KeyValueLockingStrategy::class
] = [
'hostname' => 'valkey.internal',
'database' => 0,
'password' => 'secret',
'persistentConnection' => true,
'ttl' => 10,
// TLS / Sentinel options as above
];
'options' => [
'serializer' => 'php' | 'igbinary' | 'none' | 'auto',
// …
],
text
Classes/
├── Cache/Backend/
│ └── KeyValueBackend.php (extends TYPO3 Core RedisBackend)
├── Session/Backend/
│ └── KeyValueSessionBackend.php (implements SessionBackendInterface)
├── Locking/
│ └── KeyValueLockingStrategy.php (implements LockingStrategyInterface)
└── Connection/
├── KeyValueConnectionFactory.php
├── SentinelResolver.php
├── TlsContextBuilder.php
└── ValueObject/
├── ConnectionParams.php
└── Endpoint.php
bash
composer install
vendor/bin/phpunit -c Tests/phpunit.xml --testsuite=Unit
vendor/bin/phpunit -c Tests/phpunit.xml --testsuite=Functional # needs Redis
vendor/bin/phpstan analyse Classes --level=8
vendor/bin/php-cs-fixer fix Classes Tests --config=vendor/moselwal/dev/.php-cs-fixer.dist.php