I've got a laravel application that is using Redis for caching and session storage. Data pulls in from an API using Guzzle. I'm trying to set up the Guzzle client to use it's built in cache plugin, and would like to use Redis as the storage engine, rather than the file system storage that Doctrine seems to use.
Guzzle documentation says to set the plugin up in the code like this:
$cachePlugin = new CachePlugin(array(
'storage' => new DefaultCacheStorage(
new DoctrineCacheAdapter(
new FilesystemCache('/path/to/cache/files')
)
)
));
Since I interact with the cache in the Laravel side of things just using the built in Cache object, I'm not sure how to translate that knowledge for setting up this aspect of Guzzle.
Since I can find absolutely no information on Redis with Guzzle, I'm hoping someone can point me in the right direction.
Seems you need an additional library which can be installed via composer:
https://github.com/M6Web/RedisBundle/tree/master
They define an adapter for Redis which you can couple with the cache plugin:
https://github.com/M6Web/RedisBundle/tree/master#guzzle-redis-cache-adapter
Related
I have an older codebase which has oauth2client CredentialsField as one of the fields to be added in django models. Since library deprecated, I have to migrate it to google-auth/oauthlib library but there isnt seem to be any support for django models or counter part of above mentioned field.
What I figured out is I need to save access and refresh token and if I need to call function like refresh authorization, I need to create a credentials object in google-auth library and use methods inside it.
My db is heavily dependent on CredentialsField in oauth2client, is there any other less riskier way than migrating all data and change legacy model map?
I am looking for a cache implementation for an Angular2 application.
For example, we have a million Movie objects stored on a server (i.e. enough that we don't want to grab them all at once). On the server, a REST endpoint is available : getMovie(String id)
Back on the client side, the cache should provide a simple way to get a movie from Angular, something like cache.getMovie(id:string): Observable<Movie>. This will hit the REST endpoint only for the first call, and store it locally for later requests.
Angular1 has angular-cache or the $cacheFactory, with LRU support and other great functionalities.
I started implementing a basic cache using a local HashMap, but that seems like a very common need.
Is there a good in-memory cache implementation for Angular2 yet?
I would use lscache and extend it providing few underlying storages: localStorage, sessionStorage, and self-implmented memoryStorage. TypeScript definitions are already available.
I am trying to use low level api with Laravel 5. from code I used
$specialFeed = FeedManager::getClient->feed('special', '42')
But there is no method getClient. Could you please help me how I can use low level api for getstream in Laravel?
The getClient function was added on the version 2.2.2, you should make sure to pull that or a more recent version to use this functionality.
Did you follow the setup steps from the documentation? In order to use the feed manager facade you need to configure Laravel accordingly.
If you that does not solve the issue, can you share more information (eg. your configurations, the version of the lib that you are using, the version of Laravel...)
Just trying to understand how Capsule works in laravel. Everything works correctly where it is defined, however, as soon as a new page is opened it again take backs the old connection information instead of the new connection which is defined.
I believed setAsGlobal() basically makes it available for that particular session atleast, however, I guess I am conceptually wrong here.
It would be really nice if someone can guide through the right way to make the new database connection available globally VIA CAPSULE, there are various other ways, however this seems more promising.
It would be really nice if someone could explain the following commands in more simpler way (the comments are written as per in the documentation, however, something above that would be really nice):
// Set the event dispatcher used by Eloquent models... (optional)
$capsule->setEventDispatcher(new Dispatcher(new Container));
// Set the cache manager instance used by connections... (optional)
$capsule->setCacheManager(...);
// Make this Capsule instance available globally via static methods... (optional)
$capsule->setAsGlobal();
// Setup the Eloquent ORM... (optional; unless you've used setEventDispatcher())
$capsule->bootEloquent();
Any help would really be appreciated. Thank you.
Check my answer at https://stackoverflow.com/a/34837068/1216285 to use Capsule out of Laravel scope in your app. Since all the laravel components are decoupled and served as independent components in laravel project, you can use them in your app easily.
I'm in Lumen, inside a Controller, and I would like to cache a computation's result in a simple and easy way, without using database or external services, so I was looking for save the cache in the filesystem. In Laravel's documentation there is cited the file driver:
By default, Laravel is configured to use the file cache driver, which
stores the serialized, cached objects in the filesystem.
And I can see it, configured as Default Cache Store, inside config/cache.php.
In Lumen's documentation i can't see anything about the file driver and I find nothing like the file cache.php inside Lumen installation.
So my question is if I can use the file cache driver in Lumen (by setting CACHE_DRIVER=file) or if it is discouraged, not supported, not implemented or something else?
In Lumen in .env.example you have by default:
CACHE_DRIVER=memcached
So all you need is to change filename from .env.example to .env and set
CACHE_DRIVER=file
If you read Caching in Lumen you'll see in example:
$value = Cache::store('file')->get('foo');
so file driver is supported by Lumen.
If you also read Lumen Configuration you can read here that you can copy configuration files you need (in case you need them) and load them manually. You can see default Luman cache config file here: https://github.com/laravel/lumen-framework/blob/5.1/config/cache.php