简体   繁体   中英

How I can update key of Laravel cache?

i store some id in cache like this :

$ids = Cache::remember('customer', 120, function () {
        return [1,2,3,4,5,6,7,8,9];
    });

how can remove 1 and 2 from cache?

In your case when you call Cache::remember , laravel will store the array [1,2,3,4,5,6,7,8,9] as a serialized string. So in your case if you want to remove 1,2 , you have to call Cache::remember again.

If you want to store an array and remove some value inside, you'd better use redis instead,in redis command you can use SADD to store values like SADD customer 1 2 3 4 .And remove values with SREM customer 1 2 .And get all with SMEMBERS customer .You can use it in php with predis

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM