You can create a simple class to store this information for you. For example, you can add the following to config / initializers / my_keep.rb:
class MyKeep def self.the_array @@the_array ||=
In your application, the first time MyKeep.the_array call MyKeep.the_array array will be populated from the database, so you can do this in the same file or in the after_initialize block in the application.rb file. Then you can add the array using MyKeep.add(element) , and you can get the value of the array using MyKeep.the_array . This class should not be reinstalled on every request.
source share