Replies: 1 comment
-
Sometimes we want to hit the cache multiple times. Say I want to read a key, update it and another part of the app (but same request) needs to retrieve the updated entry. Caching the cache in php memory would always return the old value except you override all other methods as well (
$store = [];
cache()->get('foo'); // hits the cache and stores result in $store
// $store is now: [ 'foo' => 'bar' ] When using // cache has: 'baz' => 'hello'
cache()->pull('baz'); // hits cache, stores in $store variable, removes key from cache
// hello
cache()->get('baz'); // checks $store variable, returns value from variable
// hello The |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
As you can see in the image here, we are calling the same key multiple times in the same request.
In each case, it takes
0.16
or even0.26
milliseconds. As a result, we will see that even if the caches on the same key are many, it will take quite some time....
so i was trying something, if i could I override the method
get()
of theclass Illuminate\Cache\Repository
as in this: QI will be able to put any keys that already have been hited in a php array in in custom class
CacheHandler
for example :Beta Was this translation helpful? Give feedback.
All reactions