Skip to content

Instantly share code, notes, and snippets.

@rgaufman
Created December 21, 2020 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rgaufman/31872f10892c6bf6e9809466c6b5aac3 to your computer and use it in GitHub Desktop.
Save rgaufman/31872f10892c6bf6e9809466c6b5aac3 to your computer and use it in GitHub Desktop.
I'm trying to switch from :dalli_store to :mem_cache_store.
With :mem_cache_store, I get this:
```
Rails.cache.fetch("zone#{zone.id}_latest_event") do
Event.where(zone: zone).desc(:starts_at).for_recording_create.limit(1).first
end
=> nil
Event.where(zone: zone).desc(:starts_at).for_recording_create.limit(1).first
=> #<Event _id: 5fe0cf57cf2048d63bb3c9f1...
```
With :dalli_store, I get this:
```
Rails.cache.fetch("zone#{zone.id}_latest_event") do
Event.where(zone: zone).desc(:starts_at).for_recording_create.limit(1).first
end
=> #<Event _id: 5fe0cf57cf2048d63bb3c9f1...
Event.where(zone: zone).desc(:starts_at).for_recording_create.limit(1).first
=> #<Event _id: 5fe0cf57cf2048d63bb3c9f1...
```
It seems that :mem_cache_store is caching nil as a value, while :dalli_store is not? - How can I stop :mem_cache_store from doing this?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment