-
Notifications
You must be signed in to change notification settings - Fork 46
Closed
Description
Hi,
Using this package for api request. Trying to add caching to reduce DB lookups with this package LaraGear CacheQuery. Could you maybe recommend where in your package this would be best added.
For example to cache all posts to redis something like this needs to be added somewhere in your code: Post::cache(null, Post::class)
. Tried to find the best place but so far without luck. I looked into adding a scope but it fails with an error:
class Server extends BaseServer {
......
public function serving(): void
{
....
Post::addGlobalScope(new CacheScope());
.....
The CacheScope:
class CacheScope implements Scope
{
public function apply(Builder $builder, Model $model)
{
// cache indefinite with key App\Models\Post
$builder->cache(null, $model::class);
}
}
The error i get: Lost connection and no reconnector available.
Any recommendation or hints in the right direction would be much appreciated.
Thanks.
Metadata
Metadata
Assignees
Labels
No labels