In my Rails application I need to query a binary file database on each page load. The query is read only. The file size is 1.4 MB. I have two questions:
1) Does it make sense to cache the File object in a class variable?
def some_controller_action
@@file ||= File.open(filename, 'rb')
# binary search in @@file
end
2) Will the cached object be shared across different requests in the same rails process?