D
D
Denis2018-06-05 07:09:37
memcached
Denis, 2018-06-05 07:09:37

How to use the same cache on different domains in Laravel?

Hello.
I have my own VDS.
It contains Memcached, Apache
Most of the data I enter into Memcached
There are two sites api.site.ru and operator.site.ru
Requests from applications come to api.site.ru , everything
is written to the cache like this

$value = Cache::rememberForever('users', function() {
    return DB::table('users')->get();
});

Then, at the right moment, the cache is cleared on the api.site.ru website, no questions asked. But the cache is not cleared on the operator.site.ru, what to do? read that it is necessary to put sites from one user. Actually that's what I do. These two sites are on the same user in Debian Only Cache::flush() helps; but that's not the way out
Cache::forget('users');

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Sokolov, 2018-06-05
@Virtus_pro

Look at the implementation. /Illuminate/Cache/MemcachedStore
There, on line 103 , you can see that prefix is ​​used in addition to the key:
I did not dig deeper into the Laravel sources. Most likely, the prefix consists of a unique key from the config.
For your task, you need to find the moment of initialization of this Store and make sure that the same prefix is ​​​​used for both api and operator.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question