Here is my problem.
- Our tech. writer or customer service will often create new or edit existing copies for out web app.
- I need to store the text bits in the DB so the app can list, sort, etc… They will be relational too, but mostly for admin purposes (ex: get all texts that are related to payment, etc…)
- Up to 30-40 different of these text bits could be displayed on one page.
- I want to avoid running queries every time a page is rendered.
- Text will be rendered on a page using a helper method.
- The size of the collection won’t be that big. They are mostly copies for the site, but we don’t want our developers making copy changes.
I was thinking of a way to do this and had these ideas
- Keep the texts in DB, but use Rails cache store to help serving them. Expire the cache upon updates, etc…
- Use MongoDB to take advantage of its caching.
- Store the texts in files and serve from the files
Maybe I am totally on a wrong path and handle this differently, but I am not sure what the best way to serve just a small amount of semi-dynamic texts other than making changes to the view file very often.
Any advice is welcome 🙂
Thanks
The fastest way to serve this content will be via memcached and easiest to setup in my opinion (less hassle then serving it form mongo). Save you content in database and cached on view level.
So all you have to to is for example in view (please check this syntax from view as this goes out of top my head):
In your development:
or Production something like that if you run app on heroku:
Then add time_stamp in this model it automatically get expired. (you can also use Rails.cache without memcached or as File store but depends on your settings on server how much memory/space you can spare.