[英]Invalidating individual keys from rack-cache?
Let's say a path on my rails app got stuck in rack cache. 假设我的rails app上的路径卡在机架缓存中。 Is there a way to say: "/games/zelda" should be removed/invalidated from rack-cache? 有没有办法说:“/ games / zelda”应该从机架缓存中删除/无效?
Assumtions Assumtions
MyApp
您的rails应用程序名为MyApp
Step 1 obtain a normalized key 步骤1获取规范化密钥
mock_request = Rack::MockRequest.env_for('/games/zelda', {"SERVER_NAME"=>"www.myapp.com"})
key = Rack::Cache::Key.call(Rack::Cache::Request.new(mock_request))
Step 2 retrieve storage objects 第2步检索存储对象
metastore_uri = MyApp::Application.config.action_dispatch.rack_cache[:metastore]
entitystore_uri = MyApp::Application.config.action_dispatch.rack_cache[:entitystore]
metastore = Rack::Cache::Storage.instance.resolve_metastore_uri(metastore_uri)
entitystore = Rack::Cache::Storage.instance.resolve_entitystore_uri(entitystore_uri)
Step 3 retrieve the metadata 第3步检索元数据
stored_meta = metastore.read(key)
Step 4 purge the entity store for each compression type 步骤4清除每个压缩类型的实体存储
stored_meta.each do |sm|
entitystore.purge(sm[1]["X-Content-Digest"])
end
Step 5 purge the metastore 步骤5清除Metastore
metastore.purge(key)
I hope this helps. 我希望这有帮助。
You can either delete one key or all keys from an Memcached instance. 您可以从Memcached实例中删除一个密钥或所有密钥。 Unfortunately doesn't allow to list all keys. 不幸的是,不允许列出所有密钥。 Therefore you cannot iterate over all keys and just delete the one you want to invalidate. 因此,您无法迭代所有键,只删除要使其无效的键。
That said I see two options: 那说我看到两个选择:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.