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

TLS connexion for (P)Redis #679

Closed
FlorentPoinsaut opened this issue Mar 20, 2019 · 2 comments
Closed

TLS connexion for (P)Redis #679

FlorentPoinsaut opened this issue Mar 20, 2019 · 2 comments

Comments

@FlorentPoinsaut
Copy link

Configuration

  • PhpFastCache version: 7.0.5
  • PhpFastCache API version: 2.0.4
  • PHP version: PHP 7.1.27-1+0~20190307202204.14+stretch~1.gbp7163d5 (cli) (built: Mar 7 2019 20:22:04) ( NTS )
  • Operating system: Debian Stretch

Is your feature request related to a problem? Please describe.
I would like to use phpfastcache with a Redis server configurated with a TLS connexion.

Describe the solution you'd like
Add a scheme optionnal option to Redis and Predis configurations.

Describe alternatives you've considered
Add a tls boolean option to Redis and Predis configurations to replace tcp scheme by tls.

Additional context
Part of Predis README for Redis server connexion: https://github.com/nrk/predis/#connecting-to-redis

@FlorentPoinsaut
Copy link
Author

As workaround, instead of:

$cache = $this->phpfastcache->get('redis');

I use:

$instanceName = 'predis';
if (array_key_exists($instanceName, $this->phpfastcache->getInstances())) {
	$cache = $this->phpfastcache->get($instanceName);
} else {
	$config = $this->phpfastcache->getConfig();

	$predisConfig = array_merge($config['drivers']['redis']['parameters'], ['scheme' => 'tls']);

	$predisClient = new \Predis\Client($predisConfig);

	$cache = CacheManager::getInstance('predis', new Config([
		'predisClient' => $predisClient
	]));

	$this->phpfastcache->createInstance($instanceName, $cache);
}

@Geolim4
Copy link
Member

Geolim4 commented Mar 21, 2019

Hello,

I'll consider adding this to the 7.1.x eventually.
But you did the right thing by using an external predis instance with exotic configurations.

The 7.1 should be released around the first day of summer :)

Cheers,
Georges.

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

No branches or pull requests

2 participants