Giter VIP home page Giter VIP logo

cache_tab's Introduction

In-memory cache application for Erlang / Elixir apps

CI Coverage Status Hex version

cache_tab application is intended to proxy back-end operations for Key-Value insert, lookup and delete and maintain a cache of those Key-Values in-memory, to save back-end operations.

Operations are intended to be atomic between back-end and cache tables.

The lifetime of the cache object and the max size of the cache can be defined as table parameters to limit the size of the in-memory tables.

Building

cache_tab application can be build as follow:

make

It is a rebar-compatible OTP application. Alternatively, you can build it with rebar:

rebar get-deps compile

Usage

You can start the application with the command:

$ erl -pa ebin -pa deps/*/ebin
Erlang/OTP 18 [erts-7.1] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

Eshell V7.1  (abort with ^G)
1> application:start(cache_tab).

Then, you can create a table for a specific type of data to cache. You can create several tables to separate your cached data. The following command will create a table named tab_name:

cache_tab:new(tab_name, [{life_time, Seconds}, {max_size, N}]).

The optional life_time option is used to define cache entry expiration. The optional max_size option is used to limit number of entries to add in cache.

You can insert data into the cache with:

cache_tab:insert(tab_name, <<"key">>, <<"value">>, fun() -> do_something() end).

Cache inserts are designed to be able to act as a proxy to backend insert. That's the purpose of the fun called as last parameter (do_something). Return of the fun is ignored, but if it crashes, cache will not be stored. If value did not change compared to previous insert, the fun will not be called, saving possibly unneeded write operations

You can also lookup data from the cache:

cache_tab:lookup(tab_name, <<"key">>, fun() -> read_value_if_not_cached() end).

The fun in last parameter is used to read and cache the value from your back-end if it is not already in cache.

It is expected to return either {ok, Value} or error.

You can delete entries from back-end and cache with command:

cache_tab:delete(tab_name, <<"key">>, fun() -> do_something() end),

Info command will report about the hits / misses to help you tune your cache size / lifetime parameters:

cache_tab:info(tab_name, Info).

Info parameter can be: size, ratio or all.

Development

Test

Unit test

You can run eunit test with the command:

$ make test

cache_tab's People

Contributors

alexeyshch avatar badlop avatar jamielinux avatar loguntsov avatar mremond avatar prefiks avatar santosh653 avatar weiss avatar zinid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cache_tab's Issues

Feature request: hook on cache entry removal

Can we have a hook/mechanism on cache entry removal. ?
Eg . After timeout the entry is removed directly can we get mechanism of flushing the entry to DB / or do some operation on timedout removal of entry in ets_cache module ?

Mix doesn't fetch `include` folder

When using from Elixir this is common error:

===> Compiling src/cache_tab_app.erl failed
src/cache_tab_app.erl:33: can't find include file "ets_cache.hrl"
src/cache_tab_app.erl:88: undefined macro 'DEFAULT_MAX_SIZE'

src/cache_tab_app.erl:61: function init_ets_cache_options/0 undefined

I figured out, that the workaround is to add ets_cache.hrl in directory include manualy

 <summary>This is <b>tree</b> output of filestructure fetched by the <b>mix</b></summary>
.
├── _build
│   └── default
│       └── plugins
│           ├── pc
│           │   ├── ebin
│           │   │   ├── pc.app
│           │   │   ├── pc.beam
│           │   │   ├── pc_compilation.beam
│           │   │   ├── pc_port_env.beam
│           │   │   ├── pc_port_specs.beam
│           │   │   ├── pc_prv_clean.beam
│           │   │   ├── pc_prv_compile.beam
│           │   │   └── pc_util.beam
│           │   ├── LICENSE
│           │   ├── README.md
│           │   ├── rebar.config
│           │   ├── rebar.lock
│           │   └── src
│           │       ├── pc.app.src
│           │       ├── pc_compilation.erl
│           │       ├── pc.erl
│           │       ├── pc_port_env.erl
│           │       ├── pc_port_specs.erl
│           │       ├── pc_prv_clean.erl
│           │       ├── pc_prv_compile.erl
│           │       └── pc_util.erl
│           └── rebar3_hex
│               ├── ebin
│               │   ├── rebar3_hex.app
│               │   ├── rebar3_hex.beam
│               │   ├── rebar3_hex_config.beam
│               │   ├── rebar3_hex_cut.beam
│               │   ├── rebar3_hex_docs.beam
│               │   ├── rebar3_hex_http.beam
│               │   ├── rebar3_hex_info.beam
│               │   ├── rebar3_hex_key.beam
│               │   ├── rebar3_hex_owner.beam
│               │   ├── rebar3_hex_pkg.beam
│               │   ├── rebar3_hex_search.beam
│               │   ├── rebar3_hex_tar.beam
│               │   ├── rebar3_hex_user.beam
│               │   └── rebar3_hex_utils.beam
│               ├── LICENSE
│               ├── README.md
│               ├── rebar.config
│               ├── rebar.lock
│               └── src
│                   ├── rebar3_hex.app.src
│                   ├── rebar3_hex_config.erl
│                   ├── rebar3_hex_cut.erl
│                   ├── rebar3_hex_docs.erl
│                   ├── rebar3_hex.erl
│                   ├── rebar3_hex.hrl
│                   ├── rebar3_hex_http.erl
│                   ├── rebar3_hex_info.erl
│                   ├── rebar3_hex_key.erl
│                   ├── rebar3_hex_owner.erl
│                   ├── rebar3_hex_pkg.erl
│                   ├── rebar3_hex_search.erl
│                   ├── rebar3_hex_tar.erl
│                   ├── rebar3_hex_user.erl
│                   └── rebar3_hex_utils.erl
├── ebin
│   ├── cache_tab_sup.beam
│   ├── ets_cache.beam
│   └── ets_cache_options.beam
├── LICENSE.txt
├── README.md
├── rebar.config
├── rebar.config.script
└── src
    ├── cache_tab_app.erl
    ├── cache_tab.app.src
    ├── cache_tab.erl
    ├── cache_tab_sup.erl
    ├── ets_cache.erl
    └── ets_cache_options.erl

11 directories, 66 files

Unfortunately, I'm zero in Erlang packaging, but may be hrl filed can be included in src, or include folder can be somehow included in rebar or mix config.

Make ejabberd 13.12 fail

ERROR: Dependency dir /home/ubuntu/ejabberd/deps/p1_cache_tab failed application validation with reason:
{name_mismatch,{"/home/ubuntu/ejabberd/deps/p1_cache_tab/src/cache_tab.app.src",
{expected,p1_cache_tab},
{has,cache_tab}}}.
ERROR: 'get-deps' failed while processing /home/ubuntu/ejabberd: rebar_abort
make: *** [deps/.got] Error 1

change the application name to p1_cache_tab of cache_tab.app.src it will be ok.

Make ejabberd 15.06 fail

How ro reproduce:
git clone https://github.com/processone/ejabberd.git --branch 15.06 ejabberd
cd ejabberd
chmod +x ./autogen.sh
./autogen.sh
./configure --enable-user=$EJABBERD_USER --disable-tools --disable-pam
make

Error message:
....

usr/lib/erlang/bin/escript rebar get-deps && :> deps/.got
==> rel (get-deps)
==> ejabberd (get-deps)
Pulling p1_cache_tab from {git,"https://github.com/processone/cache_tab"}
Cloning into 'p1_cache_tab'...
ERROR: Dependency dir /usr/src/ejabberd/deps/p1_cache_tab failed application validation with reason:
{name_mismatch,{"/usr/src/ejabberd/deps/p1_cache_tab/src/cache_tab.app.src",
{expected,p1_cache_tab},
{has,cache_tab}}}.
ERROR: 'get-deps' failed while processing /usr/src/ejabberd: rebar_abort
make: *** [deps/.got] Error 1

My environment is docker container that was recently building fine.
Dockerfile.txt

recently working fine.

"undefined symbol: __sync_add_and_fetch_8' (load_failed)" on mips, mipsel and powerpc

Hi,

on the architectures mips, mipsel and powerpc it is currently not possible to use cache_tab:

=ERROR REPORT==== 14-Jul-2017::14:55:11 ===
Failed to load NIF /<>/priv/lib/ets_cache: Failed to load NIF library: '/<>/priv/lib/ets_cache.so: undefined symbol: __sync_add_and_fetch_8' (load_failed)

You can access the full build logs here:
https://buildd.debian.org/status/package.php?p=erlang-p1-cache-tab&suite=sid

Usage of new Update function

@zinid Thanks for re-writing module to update cache.
What is the importance of UpdateFun () ? when i am passing value with key in update func.
UpdateFun should always return ok to update the values ?
Can you please help me with small example of update usage ?

Strange error report at the end of the test

Environment: MacOS 10.14.2, Erlang 10.2.1

When I run make test, tests are passing fine, but I get the following error when the command ends:

=======================================================
  All 24 tests passed.
Cover analysis: /Users/mremond/devel/ejabberd-deps/cache_tab/.eunit/index.html
Coverdata export: /Users/mremond/devel/ejabberd-deps/cache_tab/.eunit/cover.coverdata
=INFO REPORT==== 23-Jan-2019::10:08:29.421301 ===
    application: cache_tab
    exited: killed
    type: temporary
=INFO REPORT==== 23-Jan-2019::10:08:29.421488 ===
    application: p1_utils
    exited: killed
    type: temporary
=ERROR REPORT==== 23-Jan-2019::10:08:29.428844 ===
Failed to load NIF /Users/mremond/devel/ejabberd-deps/cache_tab/priv/lib/ets_cache: Upgrade not supported by this NIF library. (upgrade)
=ERROR REPORT==== 23-Jan-2019::10:08:29.428940 ===
Error in process <0.434.0> with exit value:
{upgrade,[{erlang,nif_error,[upgrade],[]},
          {ets_cache,load_nif,0,[{file,"src/ets_cache.erl"},{line,301}]},
          {code_server,'-handle_on_load/5-fun-0-',1,
                       [{file,"code_server.erl"},{line,1340}]}]}

=WARNING REPORT==== 23-Jan-2019::10:08:29.429497 ===
The on_load function for module ets_cache returned:
{upgrade,[{erlang,nif_error,[upgrade],[]},
          {ets_cache,load_nif,0,[{...}|...]},
          {code_server,'-handle_on_load/5-fun-0-',1,[...]}]}

ld: library not found for -lerl_interface

create a mix project with guide https://docs.ejabberd.im/developer/extending-ejabberd/elixir/
but mix compile not pass

system macOS 10.15.5 (19F101)

erlang version

 erl                                                                                                                                               INT ✘ │ 09:31:09 AM 
Erlang/OTP 23 [erts-11.0.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe] [dtrace]

Eshell V11.0.2  (abort with ^G)

elixir version

elixir -v                                                                                                                                             ✔ │ 09:32:44 AM 
Erlang/OTP 23 [erts-11.0.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe] [dtrace]

Elixir 1.10.4 (compiled with Erlang/OTP 23)

mix.lock

%{
  "artificery": {:hex, :artificery, "0.4.3", "0bc4260f988dcb9dda4b23f9fc3c6c8b99a6220a331534fdf5bf2fd0d4333b02", [:mix], [], "hexpm", "12e95333a30e20884e937abdbefa3e7f5e05609c2ba8cf37b33f000b9ffc0504"},
  "base64url": {:hex, :base64url, "0.0.1", "36a90125f5948e3afd7be97662a1504b934dd5dac78451ca6e9abf85a10286be", [:rebar], [], "hexpm", "fab09b20e3f5db886725544cbcf875b8e73ec93363954eb8a1a9ed834aa8c1f9"},
  "cache_tab": {:hex, :cache_tab, "1.0.23", "86b08a57b015121a8fdba381c4e3d5cb464558c00982781126196f76ff60d2af", [:rebar3], [{:p1_utils, "1.0.19", [hex: :p1_utils, repo: "hexpm", optional: false]}], "hexpm", "40eeada81bc95e235cdc11e016d98994343241f4bed2d0d91a066ba05a60a652"},
  "distillery": {:hex, :distillery, "2.1.1", "f9332afc2eec8a1a2b86f22429e068ef35f84a93ea1718265e740d90dd367814", [:mix], [{:artificery, "~> 0.2", [hex: :artificery, repo: "hexpm", optional: false]}], "hexpm", "bbc7008b0161a6f130d8d903b5b3232351fccc9c31a991f8fcbf2a12ace22995"},
  "eimp": {:hex, :eimp, "1.0.15", "746d5ee661c5c81486dae65aa24b7206da92220535e1c4a70c5a3609e0b80e2b", [:rebar3], [{:p1_utils, "1.0.19", [hex: :p1_utils, repo: "hexpm", optional: false]}], "hexpm", "eee7051ea8388bfc82b6d493e14a76899721ee709e752f60df3d1ea8a345a93f"},
  "ejabberd": {:hex, :ejabberd, "20.4.0", "85563307d911e95fd92dd0f56ffe1e2d6be4d4f2361b6041f760c9a080731431", [:mix], [{:base64url, "~> 0.0.1", [hex: :base64url, repo: "hexpm", optional: false]}, {:cache_tab, "~> 1.0", [hex: :cache_tab, repo: "hexpm", optional: false]}, {:distillery, "~> 2.0", [hex: :distillery, repo: "hexpm", optional: false]}, {:eimp, "~> 1.0", [hex: :eimp, repo: "hexpm", optional: false]}, {:esip, "~> 1.0.32", [hex: :esip, repo: "hexpm", optional: false]}, {:ezlib, "~> 1.0", [hex: :ezlib, repo: "hexpm", optional: false]}, {:fast_tls, "~> 1.1", [hex: :fast_tls, repo: "hexpm", optional: false]}, {:fast_xml, "~> 1.1", [hex: :fast_xml, repo: "hexpm", optional: false]}, {:fast_yaml, "~> 1.0", [hex: :fast_yaml, repo: "hexpm", optional: false]}, {:idna, "~> 6.0", [hex: :idna, repo: "hexpm", optional: false]}, {:jiffy, "~> 1.0.4", [hex: :jiffy, repo: "hexpm", optional: false]}, {:jose, "~> 1.8", [hex: :jose, repo: "hexpm", optional: false]}, {:lager, "~> 3.6.0", [hex: :lager, repo: "hexpm", optional: false]}, {:mqtree, "~> 1.0", [hex: :mqtree, repo: "hexpm", optional: false]}, {:p1_acme, "~> 1.0", [hex: :p1_acme, repo: "hexpm", optional: false]}, {:p1_mysql, "~> 1.0", [hex: :p1_mysql, repo: "hexpm", optional: false]}, {:p1_oauth2, "~> 0.6.1", [hex: :p1_oauth2, repo: "hexpm", optional: false]}, {:p1_pgsql, "~> 1.1", [hex: :p1_pgsql, repo: "hexpm", optional: false]}, {:p1_utils, "~> 1.0", [hex: :p1_utils, repo: "hexpm", optional: false]}, {:pkix, "~> 1.0", [hex: :pkix, repo: "hexpm", optional: false]}, {:stringprep, "~> 1.0", [hex: :stringprep, repo: "hexpm", optional: false]}, {:stun, "~> 1.0", [hex: :stun, repo: "hexpm", optional: false]}, {:xmpp, ">= 1.4.6", [hex: :xmpp, repo: "hexpm", optional: false]}, {:yconf, "~> 1.0", [hex: :yconf, repo: "hexpm", optional: false]}], "hexpm", "8521609bebf5920f565178dd8021d9e43b52c30196078fdb60d9a959bb04a207"},
  "epam": {:hex, :epam, "1.0.8", "831121dc4a6fa82ac4e6491e183d7c2dbb69db123b85c97ee0cec53c3b93dc1e", [:rebar3], [], "hexpm"},
  "eredis": {:hex, :eredis, "1.2.0", "0b8e9cfc2c00fa1374cd107ea63b49be08d933df2cf175e6a89b73dd9c380de4", [:rebar3], [], "hexpm"},
  "esip": {:hex, :esip, "1.0.34", "28895ea112fc906fd2693d2b1c98292cf5b11f35866a7e42586a958f687aaeae", [:rebar3], [{:fast_tls, "1.1.6", [hex: :fast_tls, repo: "hexpm", optional: false]}, {:p1_utils, "1.0.19", [hex: :p1_utils, repo: "hexpm", optional: false]}, {:stun, "1.0.33", [hex: :stun, repo: "hexpm", optional: false]}], "hexpm", "56ea879b55cc9797c9c42df3db2e97ae08fd0cc6627e18d2540dabde11c6306e"},
  "ezlib": {:hex, :ezlib, "1.0.7", "c8adffd32e66831df77955d163d705cdcf0a3d66762e6f68f8123012e714bf05", [:rebar3], [], "hexpm", "5634b9f7112837f9338a61da1993601f4ab81615de84ff0baddcdc5a3fe940dc"},
  "fast_tls": {:hex, :fast_tls, "1.1.6", "c66709013a99ef8151eb1b0f2cc606b6d01ef7bcf8d732e4cc7527a1562e04d7", [:rebar3], [{:p1_utils, "1.0.19", [hex: :p1_utils, repo: "hexpm", optional: false]}], "hexpm", "4c16930cd5af6b3456034730ede111062da33bb643cdb927af415fef6ecd4b92"},
  "fast_xml": {:hex, :fast_xml, "1.1.41", "aa8863b33f69c91e3b333cd7e43ef9b30ce355d4b84a0e238b3219d74f71762f", [:rebar3], [{:p1_utils, "1.0.19", [hex: :p1_utils, repo: "hexpm", optional: false]}], "hexpm", "7c287341878fd6655fb09ff5dac6514fb6c79d078a53d6bc62195634944fd99c"},
  "fast_yaml": {:hex, :fast_yaml, "1.0.25", "20bacfd6b2cfb3c10965e217be450ab5f445ecf7ef85feed40001cd26620db8a", [:rebar3], [{:p1_utils, "1.0.19", [hex: :p1_utils, repo: "hexpm", optional: false]}], "hexpm", "cae061fe898c4d89433fa287eff4523482207ae3f6af8b328139e85e87050aa5"},
  "goldrush": {:hex, :goldrush, "0.1.9", "f06e5d5f1277da5c413e84d5a2924174182fb108dabb39d5ec548b27424cd106", [:rebar3], [], "hexpm", "99cb4128cffcb3227581e5d4d803d5413fa643f4eb96523f77d9e6937d994ceb"},
  "idna": {:hex, :idna, "6.0.0", "689c46cbcdf3524c44d5f3dde8001f364cd7608a99556d8fbd8239a5798d4c10", [:rebar3], [{:unicode_util_compat, "0.4.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "4bdd305eb64e18b0273864920695cb18d7a2021f31a11b9c5fbcd9a253f936e2"},
  "jiffy": {:hex, :jiffy, "1.0.4", "72adeff75c52a2ff07de738f0813768abe7ce158026cc1115a170340259c0caa", [:rebar3], [], "hexpm", "113e5299ee4e6b9f40204256d7bbbd1caf646edeaef31ef0f7f5f842c0dad39e"},
  "jose": {:hex, :jose, "1.9.0", "4167c5f6d06ffaebffd15cdb8da61a108445ef5e85ab8f5a7ad926fdf3ada154", [:mix, :rebar3], [{:base64url, "~> 0.0.1", [hex: :base64url, repo: "hexpm", optional: false]}], "hexpm", "6429c4fee52b2dda7861ee19a4f09c8c1ffa213bee3a1ec187828fde95d447ed"},
  "lager": {:hex, :lager, "3.6.10", "6172b43ab720ac33914ccd0aeb21fdbdf88213847707d4b91e6af57b2ae5c4d2", [:rebar3], [{:goldrush, "0.1.9", [hex: :goldrush, repo: "hexpm", optional: false]}], "hexpm", "5d10499461826b79c5abee18bb594b3949cbdf76d9d9fd7e66d0a558137c21c9"},
  "luerl": {:hex, :luerl, "0.3.1", "5412807630aac1aaf59ffe5a1bc09259c447b4faeb1d3fe2d4ef41b87676cb04", [:rebar3], [], "hexpm"},
  "mqtree": {:hex, :mqtree, "1.0.8", "e87dac29002d1b82c3bfbec43d0143ac68f74b0e2f5b918161b511fbdc649c0f", [:rebar3], [{:p1_utils, "1.0.19", [hex: :p1_utils, repo: "hexpm", optional: false]}], "hexpm", "b0d8bb73a9b11bbcf0292d2a1a8faed6da061e999ee4694d94f3d0afe5c1b40a"},
  "p1_acme": {:hex, :p1_acme, "1.0.6", "0b007b776331e3d6effe700fa85d63236a98dc4e6e8c3abbbf816d1bec70df3f", [:rebar3], [{:idna, "~>6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:jiffy, "~>1.0.1", [hex: :jiffy, repo: "hexpm", optional: false]}, {:jose, "~>1.9.0", [hex: :jose, repo: "hexpm", optional: false]}, {:yconf, "~>1.0.5", [hex: :yconf, repo: "hexpm", optional: false]}], "hexpm", "7cc6528cbbe7a98929e954604ec670de56ca9f7a69a14d22166e8746fbe86f10"},
  "p1_mysql": {:hex, :p1_mysql, "1.0.15", "d24ac3cc154012733801ff4f7781e7ab7843dc85cbad61e757fad601a5d0b511", [:rebar3], [], "hexpm", "4a97e0c93a8bd61acad9a6f7894a6cc31881309cb87540a4734e4c78be41df9c"},
  "p1_oauth2": {:hex, :p1_oauth2, "0.6.6", "b17053bd7a34621f9a1a7327285a3e37abd38eb1d176afccc8cfc39882ff0a44", [:rebar3], [], "hexpm", "8a5fd16fc581a50e62176ab8b78b83b6e7cc6f76f7f59f75f58d713b7c1ca7b2"},
  "p1_pgsql": {:hex, :p1_pgsql, "1.1.9", "07ff9b037954dec06b4e30e33a82ac69a5a513e2860d2e59b7f6f4af23493c45", [:rebar3], [], "hexpm", "81aab8cff0203250dd3d9cc77a0232dc9f8e56c99fd742abbaedc51a0fd633a7"},
  "p1_utils": {:hex, :p1_utils, "1.0.19", "68373d154cc199cde33b2fd0b574e8fed0b805ff173ef0bb25792071cd3b7ab2", [:rebar3], [], "hexpm", "461634ca3c47c3378ee949664c77123bcedce82dd62496514158815c9b8e1393"},
  "pkix": {:hex, :pkix, "1.0.5", "407c02c70191d0791cd9b422ac2380df5f7f8304ec26a6d3b06e0e02be688fca", [:rebar3], [], "hexpm", "b86aed212afaf019ac97bf56857366e5f01c3003f38ee050af8ba16455e13719"},
  "sqlite3": {:hex, :sqlite3, "1.1.7", "87ee5b055b23bee07127d3ce5bd5f9995026a791e20564266fbef43151f7127d", [:rebar3], [], "hexpm"},
  "stringprep": {:hex, :stringprep, "1.0.20", "676fcc698561d692f134c826cd4f563226cc20490f9fcaf31e9d704e58823758", [:rebar3], [{:p1_utils, "1.0.19", [hex: :p1_utils, repo: "hexpm", optional: false]}], "hexpm", "3a189cf4909dab6fc36265889cb1427bd2d069a4d0083ce4ef9733a290bdcaba"},
  "stun": {:hex, :stun, "1.0.33", "c67c1055d876ee102337012053ec57ff5b67a71821a2189cdc2b47dc0c2ef63d", [:rebar3], [{:fast_tls, "1.1.6", [hex: :fast_tls, repo: "hexpm", optional: false]}, {:p1_utils, "1.0.19", [hex: :p1_utils, repo: "hexpm", optional: false]}], "hexpm", "89445e327a8d738b4ccc58421ba6edaa38dd63e0aa97258ea54886ca247ed363"},
  "unicode_util_compat": {:hex, :unicode_util_compat, "0.4.1", "d869e4c68901dd9531385bb0c8c40444ebf624e60b6962d95952775cac5e90cd", [:rebar3], [], "hexpm", "1d1848c40487cdb0b30e8ed975e34e025860c02e419cb615d255849f3427439d"},
  "xmpp": {:hex, :xmpp, "1.4.7", "8915876c74114194bb1519264db944392d8c868cd3ec522145b85e17f2dbfefb", [:rebar3], [{:ezlib, "1.0.7", [hex: :ezlib, repo: "hexpm", optional: false]}, {:fast_tls, "1.1.6", [hex: :fast_tls, repo: "hexpm", optional: false]}, {:fast_xml, "1.1.41", [hex: :fast_xml, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:p1_utils, "1.0.19", [hex: :p1_utils, repo: "hexpm", optional: false]}, {:stringprep, "1.0.20", [hex: :stringprep, repo: "hexpm", optional: false]}], "hexpm", "da0713c81e274da7cf88fa4532dcf774f3038825956bd2f67fd502fe364593ab"},
  "yconf": {:hex, :yconf, "1.0.5", "581f400f3c0cffc498421246d3e074b6b440eaf3a250295a1e1c9e9ca8a0b938", [:rebar3], [{:fast_yaml, "1.0.25", [hex: :fast_yaml, repo: "hexpm", optional: false]}], "hexpm", "e396fd0b516efa71307485cf2be962bd2a24f0c076062658f48464be35e20dd8"},
}

full debug log

===> 23.0.2 satisfies the requirement for minimum OTP version 18
===> Expanded command sequence to be run: []
===> Provider: {default,do}
===> Expanded command sequence to be run: [{default,app_discovery},
                                           {bare,compile}]
===> Provider: {default,app_discovery}
===> Evaluating config script "/Users/lidashuang/demos/ejapp/deps/cache_tab/rebar.config.script"
===> Evaluating config script "/Users/lidashuang/demos/ejapp/deps/cache_tab/rebar.config.script"
===> 23.0.2 satisfies the requirement for minimum OTP version 18
===> Not adding provider hex user from module rebar3_hex_user because it already exists from module rebar3_hex_user
===> Not adding provider hex cut from module rebar3_hex_cut because it already exists from module rebar3_hex_cut
===> Not adding provider hex key from module rebar3_hex_key because it already exists from module rebar3_hex_key
===> Not adding provider hex owner from module rebar3_hex_owner because it already exists from module rebar3_hex_owner
===> Not adding provider hex repo from module rebar3_hex_repo because it already exists from module rebar3_hex_repo
===> Not adding provider hex docs from module rebar3_hex_docs because it already exists from module rebar3_hex_docs
===> Not adding provider hex search from module rebar3_hex_search because it already exists from module rebar3_hex_search
===> Not adding provider hex revert from module rebar3_hex_revert because it already exists from module rebar3_hex_revert
===> Not adding provider hex retire from module rebar3_hex_retire because it already exists from module rebar3_hex_retire
===> Not adding provider hex publish from module rebar3_hex_publish because it already exists from module rebar3_hex_publish
===> Not adding provider pc compile from module pc_prv_compile because it already exists from module pc_prv_compile
===> Not adding provider pc clean from module pc_prv_clean because it already exists from module pc_prv_clean
===> Evaluating config script "/Users/lidashuang/demos/ejapp/deps/cache_tab/rebar.config.script"
===> 23.0.2 satisfies the requirement for minimum OTP version 18
===> Not adding provider hex user from module rebar3_hex_user because it already exists from module rebar3_hex_user
===> Not adding provider hex cut from module rebar3_hex_cut because it already exists from module rebar3_hex_cut
===> Not adding provider hex key from module rebar3_hex_key because it already exists from module rebar3_hex_key
===> Not adding provider hex owner from module rebar3_hex_owner because it already exists from module rebar3_hex_owner
===> Not adding provider hex repo from module rebar3_hex_repo because it already exists from module rebar3_hex_repo
===> Not adding provider hex docs from module rebar3_hex_docs because it already exists from module rebar3_hex_docs
===> Not adding provider hex search from module rebar3_hex_search because it already exists from module rebar3_hex_search
===> Not adding provider hex revert from module rebar3_hex_revert because it already exists from module rebar3_hex_revert
===> Not adding provider hex retire from module rebar3_hex_retire because it already exists from module rebar3_hex_retire
===> Not adding provider hex publish from module rebar3_hex_publish because it already exists from module rebar3_hex_publish
===> Not adding provider pc compile from module pc_prv_compile because it already exists from module pc_prv_compile
===> Not adding provider pc clean from module pc_prv_clean because it already exists from module pc_prv_clean
===> Provider: {bare,compile}
===> Compiling cache_tab
===> Provider: {pc,compile}
===> run_hooks("/Users/lidashuang/demos/ejapp/deps/cache_tab", pre_hooks, {pc,
                                                                           compile}) -> no hooks defined

===> Linking /Users/lidashuang/demos/ejapp/deps/cache_tab/priv/lib/ets_cache.so
===> sh info:
	cwd: "/Users/lidashuang/demos/ejapp/deps/cache_tab"
	cmd: cc /Users/lidashuang/demos/ejapp/deps/cache_tab/c_src/ets_cache.o $LDFLAGS -bundle -flat_namespace -undefined suppress  -L"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/lib/erl_interface-4.0/lib" -lerl_interface -lei -o /Users/lidashuang/demos/ejapp/deps/cache_tab/priv/lib/ets_cache.so

===> 	opts: [{env,[{"AR","ar"},
                     {"AS","as"},
                     {"BINDIR",
                      "/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/erts-11.0.2/bin"},
                     {"CC","cc"},
                     {"CFLAGS"," -g -O2 -Wall"},
                     {"COLORFGBG","15;0"},
                     {"COLORTERM","truecolor"},
                     {"CPP","cpp"},
                     {"CXX","c++"},
                     {"DEBUG","1"},
                     {"DRV_CC_TEMPLATE",
                      "cc -c  -g -O2 -Wall -g -Wall -fPIC -MMD  -I\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/lib/erl_interface-4.0/include\" -I\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/erts-11.0.2/include\"   $PORT_IN_FILES -o $PORT_OUT_FILE"},
                     {"DRV_CFLAGS",
                      "-g -Wall -fPIC -MMD  -I\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/lib/erl_interface-4.0/include\" -I\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/erts-11.0.2/include\"  "},
                     {"DRV_CXX_TEMPLATE",
                      "c++ -c $CXXFLAGS -g -Wall -fPIC -MMD  -I\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/lib/erl_interface-4.0/include\" -I\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/erts-11.0.2/include\"   $PORT_IN_FILES -o $PORT_OUT_FILE"},
                     {"DRV_LDFLAGS",
                      "-bundle -flat_namespace -undefined suppress  -L\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/lib/erl_interface-4.0/lib\" -lerl_interface -lei"},
                     {"DRV_LINK_CXX_TEMPLATE",
                      "c++ $PORT_IN_FILES $LDFLAGS -bundle -flat_namespace -undefined suppress  -L\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/lib/erl_interface-4.0/lib\" -lerl_interface -lei -o $PORT_OUT_FILE"},
                     {"DRV_LINK_TEMPLATE",
                      "cc $PORT_IN_FILES $LDFLAGS -bundle -flat_namespace -undefined suppress  -L\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/lib/erl_interface-4.0/lib\" -lerl_interface -lei -o $PORT_OUT_FILE"},
                     {"EMU","beam"},
                     {"ERLANG_ARCH","64"},
                     {"ERLANG_TARGET","23.0.2-x86_64-apple-darwin19.5.0-64"},
                     {"ERL_CFLAGS",
                      " -I\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/lib/erl_interface-4.0/include\" -I\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/erts-11.0.2/include\"  "},
                     {"ERL_EI_LIBDIR",
                      "\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/lib/erl_interface-4.0/lib\""},
                     {"ERL_LDFLAGS",
                      " -L\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/lib/erl_interface-4.0/lib\" -lerl_interface -lei"},
                     {"ESCRIPT_NAME","/Users/lidashuang/.mix/rebar3"},
                     {"EXE_CC_TEMPLATE",
                      "cc -c  -g -O2 -Wall -g -Wall -fPIC -MMD  -I\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/lib/erl_interface-4.0/include\" -I\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/erts-11.0.2/include\"   $PORT_IN_FILES -o $PORT_OUT_FILE"},
                     {"EXE_CFLAGS",
                      "-g -Wall -fPIC -MMD  -I\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/lib/erl_interface-4.0/include\" -I\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/erts-11.0.2/include\"  "},
                     {"EXE_CXX_TEMPLATE",
                      "c++ -c $CXXFLAGS -g -Wall -fPIC -MMD  -I\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/lib/erl_interface-4.0/include\" -I\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/erts-11.0.2/include\"   $PORT_IN_FILES -o $PORT_OUT_FILE"},
                     {"EXE_LDFLAGS",
                      " -L\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/lib/erl_interface-4.0/lib\" -lerl_interface -lei"},
                     {"EXE_LINK_CXX_TEMPLATE",
                      "c++ $PORT_IN_FILES $LDFLAGS  -L\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/lib/erl_interface-4.0/lib\" -lerl_interface -lei -o $PORT_OUT_FILE"},
                     {"EXE_LINK_TEMPLATE",
                      "cc $PORT_IN_FILES $LDFLAGS  -L\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/lib/erl_interface-4.0/lib\" -lerl_interface -lei -o $PORT_OUT_FILE"},
                     {"HOME","/Users/lidashuang"},
                     {"ITERM_PROFILE","Default"},
                     {"ITERM_SESSION_ID",
                      "w0t1p0:8FD9F611-2940-4692-AD89-34DBC82902E5"},
                     {"LC_CTYPE","UTF-8"},
                     {"LC_TERMINAL","iTerm2"},
                     {"LC_TERMINAL_VERSION","3.3.12"},
                     {"LD","ld"},
                     {"LESS","-R"},
                     {"LOGNAME","lidashuang"},
                     {"LSCOLORS","Gxfxcxdxbxegedabagacad"},
                     {"LaunchInstanceID",
                      "C369AF12-9D56-4FD7-AC71-B4EA26595E9C"},
                     {"NM","nm"},
                     {"OBJCOPY","objcopy"},
                     {"OBJDUMP","objdump"},
                     {"P9K_SSH","0"},
                     {"P9K_TTY","old"},
                     {"PAGER","less"},
                     {"PATH",
                      "/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/erts-11.0.2/bin:/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/Library/TeX/texbin:/usr/local/share/dotnet:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Wireshark.app/Contents/MacOS:/Applications/Xamarin Workbooks.app/Contents/SharedSupport/path-bin:/Users/lidashuang/go/bin"},
                     {"PROGNAME","erl"},
                     {"PWD","/Users/lidashuang/demos/ejapp/deps/cache_tab"},
                     {"RANLIB","ranlib"},
                     {"REBAR_CONFIG",
                      "/Users/lidashuang/demos/ejapp/_build/dev/lib/cache_tab/mix.rebar.config"},
                     {"ROOTDIR",
                      "/usr/local/Cellar/erlang/23.0.2_1/lib/erlang"},
                     {"SECURITYSESSIONID","186a6"},
                     {"SHELL","/bin/zsh"},
                     {"SHLVL","2"},
                     {"SSH_AUTH_SOCK",
                      "/private/tmp/com.apple.launchd.mqT5j04wdl/Listeners"},
                     {"STRIP","strip"},
                     {"TERM","dumb"},
                     {"TERM_PROGRAM","iTerm.app"},
                     {"TERM_PROGRAM_VERSION","3.3.12"},
                     {"TERM_SESSION_ID",
                      "w0t1p0:8FD9F611-2940-4692-AD89-34DBC82902E5"},
                     {"TMPDIR",
                      "/var/folders/q_/bmw7x38529lg5zjm9wb7v0cr0000gn/T/"},
                     {"USER","lidashuang"},
                     {"XPC_FLAGS","0x0"},
                     {"XPC_SERVICE_NAME","0"},
                     {"ZSH","/Users/lidashuang/.oh-my-zsh"},
                     {"__CF_USER_TEXT_ENCODING","0x1F5:0x0:0x0"}]},
               {cd,"/Users/lidashuang/demos/ejapp/deps/cache_tab"}]

===> Port Cmd: cc /Users/lidashuang/demos/ejapp/deps/cache_tab/c_src/ets_cache.o $LDFLAGS -bundle -flat_namespace -undefined suppress  -L"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/lib/erl_interface-4.0/lib" -lerl_interface -lei -o /Users/lidashuang/demos/ejapp/deps/cache_tab/priv/lib/ets_cache.so
Port Opts: [{env,[{"AR","ar"},
                  {"AS","as"},
                  {"BINDIR",
                   "/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/erts-11.0.2/bin"},
                  {"CC","cc"},
                  {"CFLAGS"," -g -O2 -Wall"},
                  {"COLORFGBG","15;0"},
                  {"COLORTERM","truecolor"},
                  {"CPP","cpp"},
                  {"CXX","c++"},
                  {"DEBUG","1"},
                  {"DRV_CC_TEMPLATE",
                   "cc -c  -g -O2 -Wall -g -Wall -fPIC -MMD  -I\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/lib/erl_interface-4.0/include\" -I\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/erts-11.0.2/include\"   $PORT_IN_FILES -o $PORT_OUT_FILE"},
                  {"DRV_CFLAGS",
                   "-g -Wall -fPIC -MMD  -I\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/lib/erl_interface-4.0/include\" -I\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/erts-11.0.2/include\"  "},
                  {"DRV_CXX_TEMPLATE",
                   "c++ -c $CXXFLAGS -g -Wall -fPIC -MMD  -I\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/lib/erl_interface-4.0/include\" -I\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/erts-11.0.2/include\"   $PORT_IN_FILES -o $PORT_OUT_FILE"},
                  {"DRV_LDFLAGS",
                   "-bundle -flat_namespace -undefined suppress  -L\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/lib/erl_interface-4.0/lib\" -lerl_interface -lei"},
                  {"DRV_LINK_CXX_TEMPLATE",
                   "c++ $PORT_IN_FILES $LDFLAGS -bundle -flat_namespace -undefined suppress  -L\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/lib/erl_interface-4.0/lib\" -lerl_interface -lei -o $PORT_OUT_FILE"},
                  {"DRV_LINK_TEMPLATE",
                   "cc $PORT_IN_FILES $LDFLAGS -bundle -flat_namespace -undefined suppress  -L\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/lib/erl_interface-4.0/lib\" -lerl_interface -lei -o $PORT_OUT_FILE"},
                  {"EMU","beam"},
                  {"ERLANG_ARCH","64"},
                  {"ERLANG_TARGET","23.0.2-x86_64-apple-darwin19.5.0-64"},
                  {"ERL_CFLAGS",
                   " -I\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/lib/erl_interface-4.0/include\" -I\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/erts-11.0.2/include\"  "},
                  {"ERL_EI_LIBDIR",
                   "\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/lib/erl_interface-4.0/lib\""},
                  {"ERL_LDFLAGS",
                   " -L\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/lib/erl_interface-4.0/lib\" -lerl_interface -lei"},
                  {"ESCRIPT_NAME","/Users/lidashuang/.mix/rebar3"},
                  {"EXE_CC_TEMPLATE",
                   "cc -c  -g -O2 -Wall -g -Wall -fPIC -MMD  -I\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/lib/erl_interface-4.0/include\" -I\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/erts-11.0.2/include\"   $PORT_IN_FILES -o $PORT_OUT_FILE"},
                  {"EXE_CFLAGS",
                   "-g -Wall -fPIC -MMD  -I\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/lib/erl_interface-4.0/include\" -I\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/erts-11.0.2/include\"  "},
                  {"EXE_CXX_TEMPLATE",
                   "c++ -c $CXXFLAGS -g -Wall -fPIC -MMD  -I\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/lib/erl_interface-4.0/include\" -I\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/erts-11.0.2/include\"   $PORT_IN_FILES -o $PORT_OUT_FILE"},
                  {"EXE_LDFLAGS",
                   " -L\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/lib/erl_interface-4.0/lib\" -lerl_interface -lei"},
                  {"EXE_LINK_CXX_TEMPLATE",
                   "c++ $PORT_IN_FILES $LDFLAGS  -L\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/lib/erl_interface-4.0/lib\" -lerl_interface -lei -o $PORT_OUT_FILE"},
                  {"EXE_LINK_TEMPLATE",
                   "cc $PORT_IN_FILES $LDFLAGS  -L\"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/lib/erl_interface-4.0/lib\" -lerl_interface -lei -o $PORT_OUT_FILE"},
                  {"HOME","/Users/lidashuang"},
                  {"ITERM_PROFILE","Default"},
                  {"ITERM_SESSION_ID",
                   "w0t1p0:8FD9F611-2940-4692-AD89-34DBC82902E5"},
                  {"LC_CTYPE","UTF-8"},
                  {"LC_TERMINAL","iTerm2"},
                  {"LC_TERMINAL_VERSION","3.3.12"},
                  {"LD","ld"},
                  {"LESS","-R"},
                  {"LOGNAME","lidashuang"},
                  {"LSCOLORS","Gxfxcxdxbxegedabagacad"},
                  {"LaunchInstanceID","C369AF12-9D56-4FD7-AC71-B4EA26595E9C"},
                  {"NM","nm"},
                  {"OBJCOPY","objcopy"},
                  {"OBJDUMP","objdump"},
                  {"P9K_SSH","0"},
                  {"P9K_TTY","old"},
                  {"PAGER","less"},
                  {"PATH",
                   "/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/erts-11.0.2/bin:/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/Library/TeX/texbin:/usr/local/share/dotnet:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Wireshark.app/Contents/MacOS:/Applications/Xamarin Workbooks.app/Contents/SharedSupport/path-bin:/Users/lidashuang/go/bin"},
                  {"PROGNAME","erl"},
                  {"PWD","/Users/lidashuang/demos/ejapp/deps/cache_tab"},
                  {"RANLIB","ranlib"},
                  {"REBAR_CONFIG",
                   "/Users/lidashuang/demos/ejapp/_build/dev/lib/cache_tab/mix.rebar.config"},
                  {"ROOTDIR","/usr/local/Cellar/erlang/23.0.2_1/lib/erlang"},
                  {"SECURITYSESSIONID","186a6"},
                  {"SHELL","/bin/zsh"},
                  {"SHLVL","2"},
                  {"SSH_AUTH_SOCK",
                   "/private/tmp/com.apple.launchd.mqT5j04wdl/Listeners"},
                  {"STRIP","strip"},
                  {"TERM","dumb"},
                  {"TERM_PROGRAM","iTerm.app"},
                  {"TERM_PROGRAM_VERSION","3.3.12"},
                  {"TERM_SESSION_ID",
                   "w0t1p0:8FD9F611-2940-4692-AD89-34DBC82902E5"},
                  {"TMPDIR",
                   "/var/folders/q_/bmw7x38529lg5zjm9wb7v0cr0000gn/T/"},
                  {"USER","lidashuang"},
                  {"XPC_FLAGS","0x0"},
                  {"XPC_SERVICE_NAME","0"},
                  {"ZSH","/Users/lidashuang/.oh-my-zsh"},
                  {"__CF_USER_TEXT_ENCODING","0x1F5:0x0:0x0"}]},
            {cd,"/Users/lidashuang/demos/ejapp/deps/cache_tab"},
            exit_status,
            {line,16384},
            use_stdio,stderr_to_stdout,hide,eof]

===> sh(cc /Users/lidashuang/demos/ejapp/deps/cache_tab/c_src/ets_cache.o $LDFLAGS -bundle -flat_namespace -undefined suppress  -L"/usr/local/Cellar/erlang/23.0.2_1/lib/erlang/lib/erl_interface-4.0/lib" -lerl_interface -lei -o /Users/lidashuang/demos/ejapp/deps/cache_tab/priv/lib/ets_cache.so)
failed with return code 1 and the following output:
ld: library not found for -lerl_interface
clang: error: linker command failed with exit code 1 (use -v to see invocation)


stale entries not removed because lru is true by default

In lookup call handler for cache_tab:

{ok, Prio, Val} when (State#state.lru == true) or (Prio =< CleanPrio) ->

This means that stale entries can still be returned by default given:

%% Defaults
-define(MAX_SIZE, 1000).
-define(WARN, true).
-define(CACHE_MISSED, true).
-define(LRU, true).
-define(LIFETIME, 600). %% 10 minutes

How to ?

Hello How to restrict a cache to be on one node only in a cluster there are some caches which we dont want to be distributed how can we achieve it on only one node ?

cache_tab caching errors

When I cache something which returns "error", the value is cached.

For example:

> cache_tab:new(cache_test, []).
> cache_tab:lookup(cache_test, key1, fun() -> error end).
> error
> cache_tab:lookup(cache_test, key1, fun() -> {ok, 1} end).
> error

I was expecting to get 1 as a value instead of error. It seems that cache_tab is caching the error as well. Maybe the documentation is wrong and I need to return something else.

Thanks!

PS: I'm using version 1.0.4 of cache_tab

Usage and understanding cache_opts

lifetime -- is 3600 by default does this means after 3600 it deleted the complete ETS tab or it just deletes all the entries from ets table which are not used for > 3600

cache_missed - is true by default what does this mean ?

limit = 1000 be default after 1000 it deletes old entries which passed lifetime or deletes first inserted or deletes all the entries and re-puts the values ?

There is no function to update the cache element can this be taken as feature request to update the cache content for an Id . for now way is to do lookup then delete and then insert again.
cache_missed = false is not updating the content for the primary key.

app error on OpenBSD

Hi,

I have an issue using ejabberd 18.03 on OpenBSD 6.1 (erlang 19). ejabberd fails to start cache_tab beam.
I'm trying to run the standalone cache_tab app using application:start(cache_tab). and I get the following error:

Erlang/OTP 19 [erts-8.2] [source] [smp:2:2] [async-threads:10] [kernel-poll:false]

Eshell V8.2  (abort with ^G)
1> application:start(cache_tab).
{error,
    {bad_return,
        {{cache_tab_app,start,[normal,[]]},
         {'EXIT',
             {undef,
                 [{p1_options,start_link,[ets_cache_options],[]},
                  {cache_tab_app,init_ets_cache_options,0,
                      [{file,"src/cache_tab_app.erl"},{line,87}]},
                  {cache_tab_app,start,2,
                      [{file,"src/cache_tab_app.erl"},{line,61}]},
                  {application_master,start_it_old,4,
                      [{file,"application_master.erl"},{line,273}]}]}}}}}

=INFO REPORT==== 8-Apr-2018::23:30:36 ===
    application: cache_tab
    exited: {bad_return,
                {{cache_tab_app,start,[normal,[]]},
                 {'EXIT',
                     {undef,
                         [{p1_options,start_link,[ets_cache_options],[]},
                          {cache_tab_app,init_ets_cache_options,0,
                              [{file,"src/cache_tab_app.erl"},{line,87}]},
                          {cache_tab_app,start,2,
                              [{file,"src/cache_tab_app.erl"},{line,61}]},
                          {application_master,start_it_old,4,
                              [{file,"application_master.erl"},
                               {line,273}]}]}}}}
    type: temporary
2>

Currently running on 83675a2.
If you want more information I'll be glad to provide it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.