Comments (4)
ets_cache:update(graph_cache,123,#graph{id = 123 , val=2342},fun() -> ok end)
from cache_tab.
The Val
should be in the form of {ok, V}
or error
. If existing value in the cache matches Val
then UpdateFun
is not called. Otherwise UpdateFun
is called and should return ok
(otherwise the cache will not be updated).
Example 1: you want to write value a
at key 1
:
ets_cache:update(my_tab, 1, {ok, a}, fun() -> database_write(1, a), ok end).
In the example above database_write(1, a)
is not called if there is already value a
associated with the key 1
.
Example 2: you want to delete value b
associated with key 2
:
ets_cache:update(my_tab, 2, error, fun() -> database_delete(2), ok end).
In this case function database_delete(2)
won't be called if there is already error
in the cache (i.e. 'miss' is associated with key 2
in the cache).
from cache_tab.
So, simply put, ets_cache:update()
function serves two purposes:
- Writing/deleting database data with cache updates.
- Avoiding excessive writes/deletes of the same data.
from cache_tab.
Great .. and thanks @zinid
from cache_tab.
Related Issues (16)
- Hex module does not include /priv/lib/*.so files HOT 1
- "undefined symbol: __sync_add_and_fetch_8' (load_failed)" on mips, mipsel and powerpc HOT 4
- Feature request: hook on cache entry removal
- Warning: crypto:rand_uniform/2 is deprecated and will be removed in a future release; use rand:uniform/1 HOT 1
- app error on OpenBSD HOT 2
- stale entries not removed because lru is true by default
- Strange error report at the end of the test HOT 1
- Make ejabberd 15.06 fail HOT 3
- ld: library not found for -lerl_interface HOT 1
- Why we have cache_tab and ets_cache, what's the difference between them? HOT 4
- Make ejabberd 13.12 fail HOT 1
- cache_tab caching errors HOT 1
- Usage and understanding cache_opts HOT 13
- How to ? HOT 5
- Mix doesn't fetch `include` folder HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cache_tab.