问题描述
我需要在食物菜单刷新应用程序上执行两级缓存机制。我必须使用Memcache和Redis进行缓存。
首先需要检查菜单在内存缓存中是否存在,如果不存在或无法获取,则需要移至redis缓存并检查菜单是否存在,如果没有或由于某些redis问题获取而失败数据库中的菜单项。
pos_items = Rails.cache
.fetch("pos_menu_items_for_location_#{@location_id}",expires_in: 90.days) do
pos_items = RedisCache::PosMenu.fetch(location_id: @location_id) do
pos_items = PosMenuReader.new(location_id: @location_id).call
RedisCache::PosMenu.update(location_id: @location_id,menu: pos_items) unless pos_items == "working"
if pos_items == "working"
wait_for_worker_to_finish = true
else %>
<% Rails.logger.info("DEBUG::PosMenu::#{pos_menu_key} Fetched from db.") %>
<% pos_items %>
<% end
end
end %>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)