Commit eec780c9 authored by David H. Wilkins's avatar David H. Wilkins

Make reactive caching clean up after itself

- ReactiveCaching creates 2 keys per stored value - one that just
  stores a boolean true value (the `:alive` key) and one that stores
  the value. The `:alive` key that stores the boolean true is set to
  expire after `reactive_cache_lifetime` expires.

- ReactiveCaching spawns ReactiveCachingWorker to update/create the
  value as needed.

- if the `:alive` key is present when ReactiveCachingWorker executes
  the value key is updated / created.

- if the `:alive` key is NOT present, this change will cause the value
  key to be deleted and release the memory consumed in Redis for the
  key and value.

- There is no way for the value key to be re-used. If the `:alive` key
  has expired, a Rails.cache.delete is called for *both* keys
parent e6b4a14f
......@@ -137,6 +137,8 @@ module ReactiveCaching
Rails.cache.write(key, new_value)
reactive_cache_updated(*args) if new_value != old_value
end
else
Rails.cache.delete(full_reactive_cache_key(*args))
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment