XF 2.0 Redis supported out of the box?

Cheers i tried both these setups but opera browser says site unable to handle this request ?

Code:
$config['cache']['enabled'] = true;
$config['cache']['sessions'] = true;
$config['cache']['provider'] = 'Redis';
$config['cache']['config'] = [
'host' => '127.0.0.1',
'port' => 6379,
'password' => password,
'timeout' => 1,
'database' => 7,
'persistent' => 0,
];

or

Code:
$config['cache']['enabled'] = true;
$config['cache']['sessions'] = true;
$config['cache']['provider'] = 'Redis';
$config['cache']['config']  = array(
'server' => '127.0.0.1',
'port' => 6379,
'password' => password,
'timeout' => 1,
'persistent' => 0,
);
 
@eva2000 Does the following output anything for you?
Code:
php -m | grep redis

You probably need to turn the site into development mode so you can see the exception, as this early XF's request-cycle there is very little debugging support
 
redis php extension is installed
Code:
php -m | grep redis
redis
Code:
php --ri redis

redis

Redis Support => enabled
Redis Version => 3.1.3
Available serializers => php, igbinary
Code:
php -v
PHP 7.1.9 (cli) (built: Sep  6 2017 03:05:25) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.1.9, Copyright (c) 1999-2017, by Zend Technologies
Unable to load any xenforo page when either of those 2 redis config.php are set

Code:
redis-cli -h 127.0.0.1 -p 6379 -a password info          
# Server
redis_version:4.0.1
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:b9e3021da3c16feb
redis_mode:standalone
os:Linux 2.6.32-042stab116.1 x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:4.8.5
process_id:5818
run_id:ea228b7cfc22efc0fec587070967e3e0718bc083
tcp_port:6379
uptime_in_seconds:268
uptime_in_days:0
hz:10
lru_clock:11513253
executable:/usr/bin/redis-server
config_file:/etc/redis.conf

# Clients
connected_clients:1
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0

# Memory
used_memory:1369664
used_memory_human:1.31M
used_memory_rss:2355200
used_memory_rss_human:2.25M
used_memory_peak:1369664
used_memory_peak_human:1.31M
used_memory_peak_perc:101.55%
used_memory_overhead:1357464
used_memory_startup:242400
used_memory_dataset:12200
used_memory_dataset_perc:1.08%
total_system_memory:2147483648
total_system_memory_human:2.00G
used_memory_lua:37888
used_memory_lua_human:37.00K
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
mem_fragmentation_ratio:1.72
mem_allocator:jemalloc-3.6.0
active_defrag_running:0
lazyfree_pending_objects:0

# Persistence
loading:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1504685214
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:0
rdb_current_bgsave_time_sec:-1
rdb_last_cow_size:233472
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_last_write_status:ok
aof_last_cow_size:0

# Stats
total_connections_received:2
total_commands_processed:267
instantaneous_ops_per_sec:1
total_net_input_bytes:10397
total_net_output_bytes:602
instantaneous_input_kbps:0.05
instantaneous_output_kbps:0.00
rejected_connections:0
sync_full:1
sync_partial_ok:0
sync_partial_err:1
expired_keys:0
evicted_keys:0
keyspace_hits:0
keyspace_misses:0
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:98
migrate_cached_sockets:0
slave_expires_tracked_keys:0
active_defrag_hits:0
active_defrag_misses:0
active_defrag_key_hits:0
active_defrag_key_misses:0

# Replication
role:master
connected_slaves:1
slave0:ip=127.0.0.1,port=6380,state=online,offset=410689,lag=1
master_replid:03281877a4c5881c25562a7d49df4f03ca52d495
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:410689
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:410326
repl_backlog_histlen:364

# CPU
used_cpu_sys:0.10
used_cpu_user:0.06
used_cpu_sys_children:0.00
used_cpu_user_children:0.00

# Cluster
cluster_enabled:0

# Keyspace
 
Is the connnection_id not required? Never used redis personally so I’m not sure.
it shouldn't

checked nginx error.log and see invalid cache provider for 'Redis'
NGINX:
tail -100 error.log

2017/09/06 08:17:14 [error] 6029#6029: *1 FastCGI sent in stderr: "PHP message: PHP Notice:  Use of undefined constant password - assumed 'password' in /home/nginx/domains/domain.com/public/src/config.php on line 20
PHP message: PHP Fatal error:  Uncaught InvalidArgumentException: Invalid cache provider 'Redis' in /home/nginx/domains/domain.com/public/src/XF/CacheFactory.php:66
Stack trace:
#0 /home/nginx/domains/domain.com/public/src/XF/CacheFactory.php(24): XF\CacheFactory->instantiate('Redis', Array)
#1 /home/nginx/domains/domain.com/public/src/XF/App.php(453): XF\CacheFactory->create('Redis', Array)
#2 /home/nginx/domains/domain.com/public/src/XF/Container.php(28): XF\App->XF\{closure}(Object(XF\Container))
#3 /home/nginx/domains/domain.com/public/src/XF/App.php(475): XF\Container->offsetGet('cache')
#4 /home/nginx/domains/domain.com/public/src/XF/Container.php(28): XF\App->XF\{closure}(Object(XF\Container))
#5 /home/nginx/domains/domain.com/public/src/XF/App.php(1314): XF\Container->offsetGet('registry')
#6 /home/nginx/domains/domain.com/public/src/XF/Container.php(28): XF\App->XF\{closure}(Object(XF\Container" while reading response header from upstream, client: ipaddr, server: domain.com, request: "GET /index.php HTTP/2.0", upstream: "fastcgi://127.0.0.1:9000", host: "domain.com"
 
tried

Code:
$config['cache']['enabled'] = true;
$config['cache']['sessions'] = true;
$config['cache']['provider'] = 'Doctrine\Common\Cache\Redis';
$config['cache']['config']  = array(
'server' => '127.0.0.1',
'port' => 6379,
'password' => 'password',
'timeout' => 1,
'persistent' => 0,
);

Code:
PHP message: PHP Fatal error:  Uncaught Error: Class 'Doctrine\Common\Cache\Redis' not found in /home/nginx/domains/domain.com/public/src/XF/CacheFactory.php:56
Stack trace:
#0 /home/nginx/domains/domain.com/public/src/XF/CacheFactory.php(24): XF\CacheFactory->instantiate('Doctrine\\Common...', Array)
#1 /home/nginx/domains/domain.com/public/src/XF/App.php(453): XF\CacheFactory->create('Doctrine\\Common...', Array)
#2 /home/nginx/domains/domain.com/public/src/XF/Container.php(28): XF\App->XF\{closure}(Object(XF\Container))
#3 /home/nginx/domains/domain.com/public/src/XF/App.php(475): XF\Container->offsetGet('cache')
#4 /home/nginx/domains/domain.com/public/src/XF/Container.php(28): XF\App->XF\{closure}(Object(XF\Container))
#5 /home/nginx/domains/domain.com/public/src/XF/App.php(1314): XF\Container->offsetGet('registry')
#6 /home/nginx/domains/domain.
 
I edited my post (it should be RedisCache) but regardless of that, there's more to it. Give me some time and I'll come back and tell you how to configure it.
 
@Chris D that gives an error:

Code:
PHP message: PHP Fatal error:  Uncaught Error: Call to a member function get() on null in /home/nginx/domains/lw-addons.net/public/src/vendor/doctrine/cache/lib/Doctrine/Common/Cache/RedisCache.php:66

Looking at it, XF is passing the config through the constructor, but the redis classes don't accept it like that (there is no constructor).

Liam
 
And, with the PredisCache class (not sure of the difference there), it gives a different error as it has a constructor, but it's expecting an object.
Code:
PHP message: PHP Fatal error:  Uncaught TypeError: Argument 1 passed to Doctrine\Common\Cache\PredisCache::__construct() must be an instance of Predis\ClientInterface, array given, called in /home/nginx/domains/lw-addons.net/public/src/XF/CacheFactory.php on line 56 and defined in /home/nginx/domains/lw-addons.net/public/src/vendor/doctrine/cache/lib/Doctrine/Common/Cache/PredisCache.php:24

Liam
 
Sorry, neglected to come back and update you on this.

If you want to use Redis right now then you need to add something similar to the following to config.php:
PHP:
$config['cache']['enabled'] = true;
$config['cache']['sessions'] = true;
$config['cache']['config'] = [
    'host' => '127.0.0.1'
];
$config['cache']['provider'] = function(array $config)
{
    if (!class_exists('Redis'))
    {
        throw new \LogicException("Cannot load Redis cache provider without Redis");
    }

    $config = array_replace([
        'host' => '',
        'port' => 6379,
        'timeout' => 0.0,
        'password' => '',
        'database' => 0,
        'persistent' => false,
        'persistent_id' => ''
    ], $config);

    $r = new \Redis();

    if ($config['persistent'])
    {
        $r->pconnect($config['host'], $config['port'], $config['timeout'], $config['persistent_id']);
    }
    else
    {
        $r->connect($config['host'], $config['port'], $config['timeout']);
    }

    if ($config['password'])
    {
        $r->auth($config['password']);
    }

    if ($config['database'])
    {
        $r->select($config['database']);
    }

    $cache = new \Doctrine\Common\Cache\RedisCache();
    $cache->setRedis($r);
    return $cache;
};
You might see from that what the supported config values are and their defaults. Realistically you can get away with just providing only the host value. The host value also supports a socket path too.

However...

In XF2 Beta 2 you will be able to simply do this:
PHP:
$config['cache']['enabled'] = true;
$config['cache']['sessions'] = true;
$config['cache']['config'] = [
    'host' => '127.0.0.1'
];
$config['cache']['provider'] = 'Redis';
That should make it a bit easier :)
 
Back
Top Bottom