laravel缓存以user-permissions:userid命名 更新时怎么处理 userid为变量
时间: 2023-08-06 12:06:49 浏览: 47
如果你想使用变量替换缓存键中的userid,则可以像下面这样使用Laravel中的缓存替换:
```php
$user_id = 1;
$key = 'user-permissions:'.$user_id;
$value = Cache::get($key);
// 更新缓存
Cache::put($key, $value, $minutes);
// 删除缓存
Cache::forget($key);
```
这样,你就可以在缓存键中使用变量来动态地生成缓存键,而不需要手动拼接字符串。请注意,变量必须在缓存键中使用冒号分隔符进行分隔。
相关问题
laravel缓存以user-permissions:userid命名 全部更新此类时怎么处理 userid为变量
如果你想更新所有以`user-permissions:userid`命名的缓存,其中`userid`是一个变量,你可以使用Laravel的缓存标签来完成此任务。具体步骤如下:
1. 在写入缓存时,使用`tags`方法添加标签:
```php
$user_id = 1;
$key = 'user-permissions:'.$user_id;
$value = Cache::get($key);
// 写入缓存并添加标签
Cache::tags('user-permissions')->put($key, $value, $minutes);
```
2. 然后,你可以使用`flush`方法来清除所有带有特定标签的缓存:
```php
Cache::tags('user-permissions')->flush();
```
这将删除所有以`user-permissions:userid`命名的缓存。
请注意,使用标签清除缓存时,只有带有特定标签的缓存才会被删除。如果你有其他使用相同标签的缓存,它们也会被一起删除。因此,确保在使用标签时,只为需要一起清除的缓存添加相同的标签。
Task :react-native-reanimated:downloadFolly FAILED
I apologize for the error you encountered. The "Task :react-native-reanimated:downloadFolly FAILED" error typically occurs when there is an issue with downloading the Folly library for React Native Reanimated.
To resolve this issue, you can try the following steps:
1. Make sure you have a stable internet connection.
2. Clean the Gradle cache by running the following command:
```
./gradlew clean
```
3. Delete the `node_modules` folder and reinstall the dependencies by running:
```
npm install
```
4. If you're using Yarn, run:
```
yarn install
```
5. Make sure you have the necessary permissions to download external dependencies.
6. If the issue persists, try updating React Native Reanimated to the latest version by running:
```
npm install react-native-reanimated@latest
```
7. If you're using Yarn, run:
```
yarn upgrade react-native-reanimated@latest
```
If none of these solutions work, please provide more details about your environment, such as the version of React Native, the operating system, and any other relevant information. This will help in diagnosing the issue more accurately and providing a targeted solution.