Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想使用 rails 运行 NOn_cached 查询。有什么帮助吗?
Rails 只会在请求-响应周期内缓存查询结果,因此它只会在请求期间有效。
您应该能够使用未缓存的命令
未缓存的做 find(blah) 结束
至少在控制器动作中。
另一种(糟糕!)方法是添加一个查询属性来破坏缓存
where("name= ? OR 0= ?", 'smith', rand(100))
或类似的,这样你就得到 OR '0=0.3567' 这对于每个请求总是错误的并且不同。
你真的很想使用未缓存的:)