MemoryStore should make use of an :expires_in option?

Hi there, has anyone ever looked at making ActiveSupport::Cache::MemoryStore respect the :expires_in option?

I had a go, and built a plugin to add it.

ActiveSupport::Cache::ExpiringMemoryStore http://github.com/matthewrudy/expiring_memory_store

It should work in the same way MemcacheStore does with :expires_in.

Although it will use up more memory that the basic MemoryStore, can anyone see any other problem with it? (it's not threadsafe, but nothing is apparently, including 'require')

It's currently our default cache_store at work, will see how that works out in production.

The whole Rails framework is threadsafe, so I’d think twice before stating that “nothing is”.

threadsafe, but nothing is apparently, including 'require')

The whole Rails framework is threadsafe, so I'd think twice before stating that "nothing is".

you obviously missed this amusing discussion on ruby-core

http://twitter.com/lifo/status/1037212939 http://is.gd/a8dn

:slight_smile:

And my point was that the default cache store (MemoryStore) is already not threadsafe. But the same :expires_in functionality can easily be applied to SynchronisedMemoryStore if needed.

http://twitter.com/lifo/status/1037212939

And that's why Rails preloads *everything* when you have config.threadsafe! in production.rb. Even in edge where Rails has moved to using autoload, it's all preloaded in threadsafe mode.

Indeed.

I haven't actually looked at how Merb eager-loads. Maybe it doesn't.

Ultimately I don't run in jruby. Thread-safety is a magic buzzword I've never made use of.

been drinking too much real ale, have a good evening.

MatthewRudy