Caching with redis and igbinary

I compiled redis with igbinary support and I'd like to use it with owncloud, I only found an example to use memcached with igbinary, since also redis has similar options I thought that something like this in config.php should work:

  'memcache.local' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => 'localhost',
    'port' => 6379,
  ),
  'filelocking.enabled' => true,
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis_options' => array(
        // Binary serializer vill be enabled if the igbinary PECL module is available
        \Redis::OPT_SERIALIZER => \Redis::SERIALIZER_IGBINARY,
  ),

I see no errors but will this really activate igbinary serializer?

Hi,

how did you came to the conslusion that this option is available in ownCloud?

There is no such option available / listed in the config.sample.php shipped with ownCloud.

In fact I was asking if it existed ...

I was reading this actually, but it's the same as config.sample.php:
https://doc.owncloud.org/server/9.1/admin_manual/configuration_server/config_sample_php_parameters.html
and found the options to use igbinary with memcached since also redis provides similar options I was wondering how hard it would be do the same for redis.

To be correct \Redis::OPT_SERIALIZER and \Redis::SERIALIZER_IGBINARY are options provided by the php_redis module I was wondering if just defining the array in that way will set the option in the php_redis module .....

In case it doesn't work/doesn't exist I'd turn the question into a feature request :slight_smile:

I think if that would be supported it would be listed in the config.sample.php or the linked documentation.

You can post feature requests at [1] as they won't get noticed and picked up in here.

[1] https://github.com/owncloud/core/issues

Yes I gave a look at /lib/private/Memcache/Memcached.php and it parses the array, my php-fu is a bit rusty ...

I edited ./lib/private/Memcache/Redis.php and forced the option in the constructor this way:

        public function __construct($prefix = '') {
            parent::__construct($prefix);
            if (is_null(self::$cache)) {
                    self::$cache = \OC::$server->getGetRedisFactory()->getInstance();
                    self::$cache->setOption(\Redis::OPT_SERIALIZER, \Redis::SERIALIZER_IGBINARY);

            }
    }

so the igbinary serializer is always used, I tested owncloud a bit and apparently everything works perfectly with the igbinary option set, I think I might even copy a few lines from Memcached.php and make Redis.php support the option .....
Well it's late here, tomorrow maybe.

If this makes sense to include in ownCloud you might even create a pull request over at https://github.com/owncloud/core/issues to get this included.

1 Like

Sorry, it doesn't make sense, just in case someone reads thiss:
Redis.php (unlike Memcache.php) uses json_encode($value); to store the values which is already faster than standard php serialize:

JSON Encode: 0.084825992584229
JSON Decode: 0.34976410865784
Serialize: 0.38241410255432
Serialize: 7.7904229164124
Igbinary Serialize: 0.046916007995605
Igbinary Serialize: 0.23396801948547

igbinary and msgpack are maybe slightly faster than json_encode but just setting them in the option like I did in in the previous post doesn't make sense.

I'll make the feature request anyway :slight_smile: