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:
- Select activities from database (20 per page)
- Select last 4 comments from each activity from database (justo 1
- 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
- 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!