contributte / redis

:floppy_disk: Redis (predis) for Nette Framework (@nette)

Home Page:https://contributte.org/packages/contributte/redis.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Journal always gets default client

jankonas opened this issue · comments

I am doing some non-traditional stuff with caching and so I found out that the RedisJournal object always gets the autowired (default) redis client instead of the one from it's connection:

$builder->addDefinition($this->prefix('connection.' . $name . '.journal'))
	->setFactory(RedisJournal::class)
	->setAutowired(false);

$builder->addDefinition($this->prefix('connection.' . $name . '.storage'))
	->setFactory(RedisStorage::class)
	->setArguments([
		'client' => $builder->getDefinition($this->prefix('connection.' . $name . '.client')), // shouldn't this be in the Journal factory too?
		'journal' => $builder->getDefinition($this->prefix('connection.' . $name . '.journal')),
		'serializer' => $config->serializer,
	])
	->setAutowired($autowired);

It's a pretty straightforward fix, but I am not sure if it is really a bug or an intended behaviour.

Also because of this the extension is not working when there is no connection named default because the journal is missing autowired client:

Fatal error: Uncaught Nette\DI\ServiceCreationException: Service 'redis.connection.xxx.journal' (type of Contributte\Redis\Caching\RedisJournal): Service of type Predis\ClientInterface required by $client in RedisJournal::__construct() not found. Did you add it to configuration file? in /app/vendor/nette/di/src/DI/Resolver.php:635

I have fixed this issue few days ago. Take a look at configuration in PR #47 , journal now does not require any autowired client – always uses correct client definition by name

You're right, I didn't notice new commits after last released version.