ruby - Rails - Store API data throughout session -


i rails fresher, in rails application fetching large data 1 site through api, each time load page takes time fetch , display data, there way store data throughout session?

yes, sure. can store in memcached or redis. community has awesome gem key value storages moneta

you don't posted code, of below assumption.

you create new session_id (or use existing one). create new element in store , use when need to.

session_id = securerandom.hex store = moneta.new(:memcached, server: 'localhost:11211') store[session_id] = 'value' store[session_id] = {a: 1, b: 2} store[session_id] = marshallablerubyobject.new 

store can expirable or can delete when don't need anymore.


Comments