def add(name, value, created_on)
      meter = fetch(name, nil)

      # If the name isn't cached, cache it and return
      return cache(name, value, created_on) unless meter

      # If the cached value is for a different day, flush it, cache the new value and return
      if meter.created_on != created_on
        flush(name)
        cache(name, value, created_on)
        return
      end

      # Add the new value to the cached value and flush if expired
      meter.value += value
      flush(name) if meter.expired?
    end
def add(name, value, created_on)
      meter = fetch(name, nil)

      # If the name isn't cached, cache it and return
      return cache(name, value, created_on) unless meter

      # If the cached value is for a different day, flush it, cache the new value and return
      if meter.created_on != created_on
        flush(name)
        cache(name, value, created_on)
        return
      end

      # Add the new value to the cached value and flush if expired
      meter.value += value
      flush(name) if meter.expired?
    end
Adds the given value to the hash
 Flushes expired data to DB