View Source SuperCache.KeyValue (SuperCache v0.6.1)
Key-Value(KV) database in memory. Each KV name is store in a partition. Can use multiple KV cache by using different KV name. This is global KV cache any process can access. The KV is store in with cache. Need to start SuperCache.start!/1 before using this module. Ex:
alias SuperCache.KeyValue
SuperCache.start!()
KeyValue.add("my_kv", :key, "Hello")
KeyValue.get("my_kv", :key)
# => "Hello"
KeyValue.remove("my_kv", :key)
KeyValue.get("my_kv", :key)
# => nil
KeyValue.add("my_kv", :key, "Hello")
KeyValue.remove_all("my_kv")
Summary
Functions
Add key-value to cache. kv_name is used to get target partition to store data. Use can use multiple kv cache by using different kv_name. You can use any type of kv_name, key & value. Format of data is {{:kv, kv_name, key}, value} in ets table. You can use other functions of SuperCache to get data.
Count number of key-value in kv_name cache.
Get value by key. Key is belong wit kv_name.
Get all keys in kv_name cache.
Remove key-value in kv_name cache. This operaton is always success.
Remove all key-value in kv_name cache.
Convert kv_name cache to list of key-value. result has format [{key, value}]
Get all values in kv_name cache.
Functions
Add key-value to cache. kv_name is used to get target partition to store data. Use can use multiple kv cache by using different kv_name. You can use any type of kv_name, key & value. Format of data is {{:kv, kv_name, key}, value} in ets table. You can use other functions of SuperCache to get data.
Count number of key-value in kv_name cache.
Get value by key. Key is belong wit kv_name.
Get all keys in kv_name cache.
Remove key-value in kv_name cache. This operaton is always success.
Remove all key-value in kv_name cache.
Convert kv_name cache to list of key-value. result has format [{key, value}]
Get all values in kv_name cache.