0

Hi,

I have module that imports data from json file to hash. Json file is pretty big so I don't want loading to take place on every request because it takes some time. It would be best to do this just on server start. I have a class variable in module called "data" which I'd like to set only on server start and then I can access to it on every request with SomeModule.data (I use mattr_accessor). I tried to import data in application config.after_initlize method but id doesnt work - data persists only on first request and on second request data is nil.

Is there any way to do this beside session, and can you give little explanation on this. I know I can save this data in session but I'd like to do this other way.

Thanks in advance

3
Contributors
2
Replies
11
Views
4 Years
Discussion Span
Last Post by lambing
1

I do not understand why you attempt to store data in the server memory which should rather be stored in database. Anyway, someone has given some ideas here.

1

Don't you want to put your code inside the initializer? Codes inside the initializer folder only run once whenever the application starts.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.