简体   繁体   中英

Clearing part of the Rails cache and not all of it with Rails.cache.clear

I'm trying to clear part of my rails cache. My problem is that there are logs that are being cached that need to be cleared but if I clear the whole cache active users will be logged out of the site.

Because I'm using a cache based session store, when the cache gets cleared the user gets logged out of their session.

I did some research and unfortunately...

If you ever need to reset your cache (say you upgraded Rails and your old cached data is no longer accurate), there's no way to do that without expiring everyone's sessions.

-- via Justin Weiss's blog

If we ever want to remedy the issue of clearing sessions when the cache is cleared we will need to store our sessions in the database instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM