T
T
TM_ID2014-06-13 16:28:10
Ruby on Rails
TM_ID, 2014-06-13 16:28:10

Sessions in the database?

I take records from the database and randomly them.
I create an array with these, already srendomlenny data.
To "always" have this ready-made array, I write it to the session.
I'm getting a CookieOverflow error due to the 4kb limit.
I find a solution in the form of storing the ActiveRecordStore session.
And the question arises - is this the right decision to store sessions in db?
Or maybe it's better to just write the finished array in db?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel Solovyov, 2014-06-13
@TM_ID

store temporary data in the cache, or rather in redis, do not write anything to the session.

D
Dimitriy, 2014-06-14
@Vakiliy

If the load is not large, then it is possible in the database, but there is no special sense.
Out of the box, in addition to CookieStore, MemCacheStore (requires gem dalli), CacheStore are available.
They are connected here: config/initializers/session_store.rb, an example of using CacheStore:

Rails.application.config.session_store :cache_store, key: '_super_app_session_key'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question