我尝试在部署Web应用程序后设置结束任务来清理Azure Redis中的缓存,以避免使旧缓存生效。我尝试了 az cli 和 Powershell 这两个命令,它们都进行了相同的重启,但是 Redis 缓存中的所有数据仍然没有刷新,即使在 activilogs 中显示重启后数据将丢失。我已经在 C0 层和 P1 层 Redis 上进行了测试。有人给了我一个刷新所有 Azure Redis 的脚本吗?我只设置 SSL 端口 3380。
这是我运行的命令:
-CLI
az redis 强制重启 --name $Redis --resource-group $ResourceGroup --reboot-type AllNodes
-Powershell:
重置-AzRedisCache -ResourceGroupName $ResourceGroup -Name $Redis -RebootType“AllNodes”-Force
谢谢你帮助我!
设置任务 Flushall Azure Redis
命令
force-reboot
用于从此MSDOC重新启动指定的Redis节点
az redis force-reboot --reboot-type {AllNodes, PrimaryNode, SecondaryNode}
[--ids]
[--name]
[--resource-group]
[--shard-id]
[--subscription]
使用
az login
登录到 Azure。
创建 Azure Redis 缓存
New-AzRedisCache -ResourceGroupName myGroup -Name mycache -Location "North Central US"
Invoke-Command -ScriptBlock { redis-cli -h <hostname>.redis.cache.windows.net -p <redisPort> -a <password> }
Invoke-Command -ScriptBlock { redis-cli flushall }
输出:
flushall
命令:另一种方法:
$redisServer.FlushAllDatabases() # Dispose connection
$redis_cache.Dispose() Write-Host "Cache flush done" -ForegroundColor Yellow