Forum: Ruby on Rails Cache layer to json api

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Dc0c8a16af7fe669ffd9bb6366f2dceb?d=identicon&s=25 maxguzenski (Guest)
on 2016-01-15 17:42
(Received via mailing list)
Hi everyone!

I have a small social website on rails that use react on view and
is just a JSON API,
with more o less 3000 users online at any moment. It runs with

When user, for example, visits its feed page, I do:

1. Select activities from database (20 per page)
2. Select last 4 comments from each activity from database (justo 1
3. Select all users referenced by activity or comment from database
users.* from users where id in (1,3,4,5,...100) )

I have a cache layer (memcached) that when I will load users, first I
load from memcached, if it not exists I read from database and put it on
BUT I also have some "listenners" on users model (and over others
referenced models like address and profile) to invalidate cache if any
field change.

The problem:
- This cache demand a lot of code.
- Sometimes cache run out of sync.
- I hate to have this listeners and they are "side effects"

My question is: Any one is doing something like that??
I search A LOT over all google about cache layer to json api and looks
that everyone is just using database directly.

I know that Rails has it own solution, but it always end up using
column, that means, I have to fetch users from database any way.

- Live with date, life is not pretty
- Buy a more powerful postgres instance... any one is using memcached
- Remover listeners, put some expires_in (1 or 2 minutos... or more) and
let app show out of sync data for a couple of minutes.

thanks for any help!
This topic is locked and can not be replied to.