Not sure were you got all of this code from… were you following an example somewhere?
This appears to be way overcomplicated for your use case.
The definitive and nearly ubiqutious method for simple object caching (incidentally, the singular form is spelled "cache," as in a small hiding place. The word comes from the French, not to be confused with cachet, which also comes from French, and means "superior status" or "prestige") is from the DHH post from 2013…
Assuming your objects are ActiveResource objects, you automatically get cache_key defined for you.
All you need to do is wrap the expensive (processing/time-intensive) code in the caching mechanism
Rails.cache.fetch(@contact)
// serialize or render the response data
end
… that's it. As explained in DHH's post from 2013, cache_key on @contact automatically includes the timestamp of when the record was last updated. When you make a change to any field the update_at timestamp changes, and so does the cache key, invalidating all caches associated with that cache key.
All of the other code you have looks like you went down a caching rabbit hole that is unnecessary. (But learning the internals of the Rails caching mechanism is a good thing for your own edification!)
-Jason