Q:

Is there any rails/ruby functions that I can use to reset a hash lookup table every 24 hours or at a specific date?

Ok so I have an app that allows users to pull App Store data, specifically top free top paid etc. The various attributes are quite limited, but users can filter by category and country. So obviously this leads to a lot of repeated queries, now normally this wouldn't be a problem, but I also use this data with google api which has a credits system. So What I want to do is save these results in my database if the results are unique. I have this all set up and fine but my only hang up is how I determine if a query has been made before, so my solution is to make a hashtable that stores all queries that have been made before and if not NULL(nil) then I call the api to fetch the data then create a new record. 
Issue is the App Store refreshes every day or so(not exactly sure the schedule but will look it up later). I would like to have this Hashtable reference function refresh or reset itself to all NULL at this interval. 
What would be the most efficient or simple way to start a refresh for this? Additionally I am kinda new to rails, so where should I place this function? In the helper modules? Controller? 
Thanks! 
Edit: 
ok so here is my HashTable helper module
module MapsHelper
    queryHistoryLookUp = {}
    i = 0
    31.times do |i|
        queryTableLookup.merge!(i =>[] ) 
    end

    def queryTableLookup(asciiNum, queryString)
        if queryTableLookup[asciiNum % 31].size == 0
            queryTableLookup[asciiNum % 31].push(queryString)
        else
        a = queryTableLookup[asciiNum % 31].size
        arrayOfQueries = queryTableLookup[asciiNum % 31]
        a.times do |i|
            if arrayOfQueries[i] == queryString
                return true
            else
                return false
            end
        end
    end
end

end
def queryHash(query)
    asciSum = 0
    query.each_char do |i|
        asciSum += i.sum 
    end
    queryTableLookup(asciSum, query)
end

end
additionally I am kinda new to rails, can I interact with these functions using Javascript, since on the client side I create the string query. 

A:

In my opinion, your best bet would be to use the Rails cache system.  It provides a method of caching data, with an optional expires_in time.
From the docs:
http://guides.rubyonrails.org/caching_with_rails.html#low-level-caching
class MyModel < ActiveRecord::Base

  def self.get_api_data(key)
    Rails.cache.fetch("my_model/api_data:#{key}", expires_in: 12.hours) do
      SomeService::API.get_data(key)
    end
  end

end

