Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache Middleware for Redis not Predis #53

Closed
ernesthernandez opened this issue May 3, 2016 · 2 comments
Closed

Cache Middleware for Redis not Predis #53

ernesthernandez opened this issue May 3, 2016 · 2 comments

Comments

@ernesthernandez
Copy link

I need to use Redis cache instead Predis because predis is more slower for multiple calls. Do you have an example to create interface?

@Kevinrob
Copy link
Owner

Kevinrob commented May 4, 2016

You use phpredis? So, you can use the doctrine cache for Redis.

[...]
use Redis;
use Doctrine\Common\Cache\RedisCache;
use Kevinrob\GuzzleCache\Strategy\PrivateCacheStrategy;
use Kevinrob\GuzzleCache\Storage\DoctrineCacheStorage;

[...]
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
// Check https://github.com/phpredis/phpredis#usage for configuration

$stack->push(
  new CacheMiddleware(
    new PrivateCacheStrategy(
      new DoctrineCacheStorage(
        new RedisCache($redis)
      )
    )
  ), 
  'cache'
);

@ernesthernandez
Copy link
Author

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants