Hi,
For a module I'm making I need to only store a value if there's not
already another value stored with that key to avoid a race condition.
Basically I try setting the value and then fetch it again. It's a
rarely set, often read sort of thing (hourly token secrets).
With MySQL / DBI just do an insert (and ignore errors).
With Redix "SETNX".
With memcached "add".
etc etc...
In my module I'm using CHI for caching of these values (in memory and/
or memcached) and then I have some custom code to write to the "real
storage". However, I'm quickly going down the path of re-implementing
too much of CHI (and badly).
So: Would there be any interest in adding an "add" command to CHI?
Obviously only some backends would support it; but that's not
unprecedented.
- ask
--
http://askask.com/