Caching in Rails

80 views
Skip to first unread message

Nicholas Henry

unread,
Jan 27, 2014, 3:26:52 PM1/27/14
to roar...@googlegroups.com
Are there any examples of caching in Rails using ROAR? Specifically, I'm looking for something similar to what active_model_serializers[1] provides/provided.

Nick Sutterer

unread,
Jan 27, 2014, 4:42:29 PM1/27/14
to roar...@googlegroups.com
You mean client-side caching? It should be actually really simple. Could you explain what exactly you're after? Is that on client or server-side?


--
You received this message because you are subscribed to the Google Groups "Roar" group.
To unsubscribe from this group and stop receiving emails from it, send an email to roar-talk+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Nicholas Henry

unread,
Jan 27, 2014, 5:22:35 PM1/27/14
to roar...@googlegroups.com
Hello Nick,

I'm after the same sort of caching you get with a server-side template. Basically, able to cache the generated JSON based on a cache key or an expiration date. From active_model_serializers, what is the equivalent in ROAR for this:

class PostSerializer < ActiveModel::Serializer
  cached  # enables caching for this serializer

  attributes :title, :body

  def cache_key
    [object, scope]
  end
end
Other references:

Thank you for your help,
Nicholas


--
You received this message because you are subscribed to a topic in the Google Groups "Roar" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/roar-talk/SHyTDvxf0kw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to roar-talk+...@googlegroups.com.

Glenn Goodrich

unread,
Feb 17, 2014, 4:57:54 PM2/17/14
to roar...@googlegroups.com
Any answer on this?

Nick Sutterer

unread,
Feb 17, 2014, 5:04:09 PM2/17/14
to roar...@googlegroups.com
This is a feature relatively simple to implement and will be done exactly the way we do it in Cells: https://github.com/apotonick/cells#caching

I am contemplating something like

```ruby
module SongRepresenter
  include ..

  caches do [id, title] end
```

In roar-rails, this will go directly to the Rails' cache store.


We don't need this feature in our products right now, so if anyone is keen on sponsoring this I'll hack it in the next days. https://pledgie.com/campaigns/16068


Cheers,

Nick
Reply all
Reply to author
Forward
0 new messages