ethanhann / Laravel-RedisStore by ethanhann

Adds functionality to the built-in Cache's RedisStore.
13,411
12
3
Package Data
Maintainer Username: ethanhann
Maintainer Contact: ethanhann@trackrevenue.com (Ethan Hann)
Package Create Date: 2017-01-15
Package Last Update: 2017-11-24
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2024-11-23 03:23:00
Package Statistics
Total Downloads: 13,411
Monthly Downloads: 4
Daily Downloads: 0
Total Stars: 12
Total Watchers: 3
Total Forks: 4
Total Open Issues: 0

Why is this useful?

The RedisStore that comes with the Laravel Cache does not compress string values out of the box. The RedisStore in this package does. Caching string values can save a ton of memory and/or network bandwidth depending on cached item size and request frequency.

How do I use it?

Install the package...

composer require ehann/laravel-redis-store

Add a custom cache driver, like this...

public function boot()
{
    Cache::extend('ehann-redis', function ($app) {
        return Cache::repository(new \Ehann\Cache\RedisStore(
            $app['redis'],
            $app['config']['cache.prefix'],
            $app['config']['cache.stores.redis.connection']
        ));
    });
}

Add the ehann-redis custom driver to the redis store config in config/cache.php...

'stores' => [
    'redis' => [
        'driver' => 'ehann-redis',
    ],
],