Reputation: 21
I've been stuck at this for days. I tried searching for similar issues in the web but no dice :(
I followed this guide
its kinda old, and I used the Doctrine\Common\Cache\RedisCache() instead of snc. The problem is that whenever i try to run:
<?php
namespace AppBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Predis\Client;
use Doctrine\Common\Cache\RedisCache;
class DefaultController extends Controller
{
/**
* @Route("/Worker", name="homepage")
*/
public function indexAction()
{
$predis = new RedisCache();
$predis->setRedis(new Client());
return $this->render('default/index.html.twig', array(
'base_dir' => realpath($this->container->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
));
}
}
It gives me an error
Catchable Fatal Error: Argument 1 passed to Doctrine\Common\Cache\RedisCache::setRedis() must be an instance of Redis, instance of Predis\Client given, called in C:\xampp\htdocs\symfony\src\AppBundle\Controller\DefaultController.php on line 22 and defined
I'm requiring predis/predis 1.1.1 in my composer.json btw
"require": {
"php": ">=5.3.9",
"symfony/symfony": "2.8.*",
"doctrine/orm": "^2.4.8",
"doctrine/doctrine-bundle": "~1.4",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.11.3",
"sensio/distribution-bundle": "~5.0",
"sensio/framework-extra-bundle": "^3.0.2",
"incenteev/composer-parameter-handler": "~2.0",
"snc/redis-bundle": "2.x-dev",
"predis/predis": "1.1.1"
Upvotes: 1
Views: 1690
Reputation: 21
It turns out that I have to use Doctrine\Common\Cache\PredisCache() with Predis\Client() if I want to use predis. (the method used in the link is outdated)
use Predis\Client;
use Doctrine\Common\Cache\PredisCache;
$predis = new PredisCache(new Client());
Upvotes: 1
Reputation: 39410
Try with:
$predis->setRedis(new \Redis());
instead of:
$predis->setRedis(new Client());
Hope this help
Upvotes: 0