PHP code example of fof / redis
1. Go to this page and download the library: Download fof/redis 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/ */
fof / redis example snippets
return [
new FoF\Redis\Extend\Redis([
'host' => '127.0.0.1',
'password' => null,
'port' => 6379,
'database' => 1
])
];
return [
new FoF\Redis\Extend\Redis([
'host' => '127.0.0.1',
'password' => null,
'port' => 6379,
'database' => 1,
'persistent' => true,
'persistent_id' => 'flarum', // groups connections into a named pool per worker
])
];
return [
new FoF\Redis\Extend\Redis([
'host' => '/var/run/redis/redis.sock',
'port' => 0,
'database' => 1,
'persistent' => true,
'persistent_id' => 'flarum',
])
];
return [
(new FoF\Redis\Extend\Redis([
'host' => '127.0.0.1',
'password' => null,
'port' => 6379,
'database' => 1,
]))
->useDatabaseWith('cache', 1)
->useDatabaseWith('queue', 2)
->useDatabaseWith('session', 3)
->useDatabaseWith('settings', 4) // Settings cache database
];
return [
(new FoF\Redis\Extend\Redis([
'connections' => [
'cache' => [
'host' => 'cache.yoursite.com',
'database' => 1,
],
'settings' => [
'host' => 'settings.yoursite.com',
'database' => 4,
],
// ... other connections
],
]))
];
return [
(new FoF\Redis\Extend\Redis([
'host' => '127.0.0.1',
'password' => null,
'port' => 6379,
'database' => 1,
]))->disable(['cache', 'queue', 'settings'])
];
return [
(new FoF\Redis\Extend\Redis([
'host' => '127.0.0.1',
'password' => null,
'port' => 6379,
'database' => 1,
]))
->useDatabaseWith('cache', 1)
->useDatabaseWith('queue', 2)
->useDatabaseWith('session', 3)
->useDatabaseWith('settings', 4)
];
return [
(new FoF\Redis\Extend\Redis([
'connections' => [
'cache' => [
'host' => 'cache.int.yoursite.com',
'password' => 'foo-bar',
'port' => 6379,
'database' => 1,
],
'queue' => [
'host' => 'queue.int.yoursite.com',
'password' => 'foo-bar',
'port' => 6379,
'database' => 1,
],
'session' => [
'host' => 'session.int.yoursite.com',
'password' => 'foo-bar',
'port' => 6379,
'database' => 1,
],
'settings' => [
'host' => 'settings.int.yoursite.com',
'password' => 'foo-bar',
'port' => 6379,
'database' => 4,
],
],
]))
];
return [
(new FoF\Redis\Extend\Redis([
'host' => '127.0.0.1',
'password' => null,
'port' => 6379,
'database' => 1,
'options' => [
'replication' => 'sentinel',
'service' => 'mymaster:26379',
]
]))
->useDatabaseWith('cache', 1)
->useDatabaseWith('queue', 2)
->useDatabaseWith('session', 3)
->useDatabaseWith('settings', 4)
];
return [
(new FoF\Redis\Extend\Redis([
'host' => '127.0.0.1',
'password' => null,
'port' => 6379,
'database' => 1,
'queue' => [
'retry_after' => 120, // seconds
'block_for' => 5, // seconds
'after_commit' => true
]
]))
->useDatabaseWith('cache', 1)
->useDatabaseWith('queue', 2)
->useDatabaseWith('session', 3)
];