Hi,
ThreadSafe::Cache and ActiveSupport::Cache are classes with 2 completely
different purposes. TS::Cache doesn''t support any of the
AS::Cache''s
features (TTL, max size, prune, etc.), but it is faster, more memory
efficient and more scalable (under concurrent load) than AS::Cache, that is
why it is being used for Rails internal caching. Notice how in the commit
where it was introduced it always replaces Hash usage, but never AS::Cache
usage.
As for the ThreadSafe::Cache#fetch method, originally it did have
ActiveSupport::Cache#fetch semantics, but since TS::Cache was aimed at
replacing naked/non-thread-safe concurrent Hash usage I chose it to be as
Hash-like as possible.
On Sunday, June 30, 2013 4:17:38 AM UTC+2, Justin Ridgewell
wrote:>
> I was monkey patching my way around issue
#10791<https://github.com/rails/rails/pull/10791> when
> I noticed that the cache store had been converted over to a
>
ThreadSafe::Cache<https://github.com/headius/thread_safe/blob/master/lib/thread_safe/cache.rb>.
> In fact, several classes now use ThreadSafe''s caches starting from
45448a5<https://github.com/rails/rails/commit/45448a578877f6a753492113d72cc3512a6f1720>.
> The main problem I''m having at with it is that it''s not
compatible with
> ActiveSupport::Cache (e.g. #fetch), so #10791 isn''t as easy as
just
> dropping an ActiveSupport::Cache in. And since MemoryStore is
thread-safe<https://github.com/rails/rails/blob/master/activesupport/lib/active_support/cache/memory_store.rb#L17>,
> I''m curious why we''re not using it instead.
>
> For me to work on #10791, would my time be better spent on making
> an ActiveSupport::Cache compatible wrapper for ThreadSafe, or changing over
> the classes that use it to MemoryStore?
>
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to rubyonrails-core+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/groups/opt_out.