ex_sider v0.2.0 RedisCache
Currently only works by merging/replacing with maps and then pull/push-ing.
In the future, this should implement Access, Enumerable and Collectable - meaning
this could then be used with Elixir’s Enum w/o limitations. These should work
independant of whether or not local caching is used.
You can let this cache its values locally and commit them back to the repo on demand. This doesn’t handle inconsistencies etc. - the use case is to have a relatively longer term storage (redis semantics) for process related data. In case a process gets restarted etc. it can quickly commit and refetch its state later on. Obviously gets tricky if multiple processes use the same redis-hash.
Conflicts and race conditions are tried to be avoided, but essentially this is a very simplistic grow-only set. (You can delete the whole thing, but not single entries for now)
This will fetch the state of the hash when it is created, and will try to keep it up to date with the external version whenever you do pulls and pushes to redis.
Summary
Functions
Delete this hash from the Redis repo and clear the local cache, if any
Returns the underlying cached map. This does not pull in changes beforehand!
Merges the fields of the given map into the RedisCache, overwriting existing fields in the cache and possibly causing local (unpushed) changes
This will checkout the initial cache state from redis upon creation
Pulls all fields of this hash from Redis and merges it with the current local cache if any. This doesn’t change the local-cache state of the RedisCache
Push all local keys/values back to the Redis repo. This simply overwrites whatever is already in there
Check if we have local unpushed changes
Functions
Merges the fields of the given map into the RedisCache, overwriting existing fields in the cache and possibly causing local (unpushed) changes.
This will checkout the initial cache state from redis upon creation.
Options:
:binary_mode- true/false depending on whether data should be put through:erlang.term_to_binaryand:erlang.binary_to_termrespectively or not (default: true)
Pulls all fields of this hash from Redis and merges it with the current local cache if any. This doesn’t change the local-cache state of the RedisCache.
Push all local keys/values back to the Redis repo. This simply overwrites whatever is already in there.