I need to make HTTP requests directly from Yves controller. It is desirable to cache the result of this request in order to reduce the time of the entire operation. Do we have something like a quickly accessible system level (or "global") cache to inject into the Yves controller?
Asked
Active
Viewed 72 times
1 Answers
1
For quick dirty fix I would suggest using redis as key value storage.
DI for storage client
<?php
const CLIENT_STORAGE = 'CLIENT_STORAGE';
/**
* @param \Spryker\Client\Kernel\Container $container
*
* @return \Spryker\Client\Kernel\Container
*/
public function provideServiceLayerDependencies(Container $container)
{
$container[static::CLIENT_STORAGE] = function (Container $container) {
return $container->getLocator()->storage()->client();
};
return $container;
}
Factory
<?php
/**
* @return \Spryker\Client\Storage\StorageClientInterface
*/
public function getStorageClient()
{
return $this->getProvidedDependency(MyBundleDependencyProvider::CLIENT_STORAGE);
}
Accessing key
<?php
$storedValue = $this->storageClient->get($myKey);
if (!empty($storedValue)) {
return $storedValue;
}
// generate and return value

Tomasz Ferfecki
- 1,263
- 14
- 22