fogfish / cache Goto Github PK
View Code? Open in Web Editor NEWErlang in-memory cache
License: Apache License 2.0
Erlang in-memory cache
License: Apache License 2.0
Hello,
Is not compiling with erlang 19 because of the type specs.
All type specs like:
-spec(new/4 :: (atom(), integer(), integer(), integer()) -> #heap{}).
Should be converted in :
-spec(new(atom(), integer(), integer(), integer()) -> #heap{}).
Silviu
Пожалуйста уточните параметры выводимой информации о состоянии кэша, правильно ли я их понимаю:
Это количество сегментов в кэше:
{heap, [integer()]} - cache segments references
Оставшееся время самому старому сигменту (мс):
{expire, [integer()]} - cache segments expire times
Общее количество записей в кэше:
{size, [integer()]} - cardinality of cache segments
Всего занято памяти Кэшем на инстанции (в словах):
{memory, [integer()]} - memory occupied by each cache segment
hello,
can you provide transaction in this lib?
when i use this lib, i maybe use like this:
Value = cache:get({global, test}, key),
NewValue = ....,
cache:put({global, test}, key, NewValue),
if no transaction ,the cache maybe modify by other progress.
(cache@localhost.localdomain)1> cache:start_link(c, [{n,10}, {ttl, 60}]).
{ok,<0.68.0>}
(cache@localhost.localdomain)2> cache:put(c, x, test, 10).
ok
(cache@localhost.localdomain)3> cache:ttl(c, x).
6
(cache@localhost.localdomain)4> timer:sleep(10000).
ok
(cache@localhost.localdomain)5> cache:ttl(c, x).
-4
(cache@localhost.localdomain)6>
the api i want to used like this:
i saved some data to the cache,and i want to get some data page and page.
of course,i can use the api -> cache:all() to replace, but not a good way because too many data.
Hello.
Thank you for your library.
I didn't find simple logic like:
This logic must be atomic as another processes can ask this key at same time.
I hoped to implement this logic by cache:apply function. But can't as this function is always putting data into cache. It doesn't compare old value with new value what can cause useless load.
What solution do you see in this situation ?
Thanks.
Nice work. I've spent some time exploring caching libraries for Erlang. And this library is really good.
Did you consider to add sharding? Currently all read/write queries go through gen_server:call to single process. And this is not good for my case.
Sharding could be added as separate library on top of "cache", or it could be implemented inside "cache". What option do you think will be better?
I am ready to do it myself and send PR to you.
With 2.3.0 there is suddenly a module named sharded_cache
. Is it possible to stick to one prefix ie. cache
? Thanks.
How can I set a limit on the use of memory, when i use this project in my App ?
I try start on VPS:
{ok, _} = cache:start_link(my_cache, [{memory, 1000000}, {n, 10}, {ttl, 60}]).
and I get this error:
** exception exit: undef
in function erlang:sysinfo/1
called as erlang:sysinfo(wordsize)
in call from cache_bucket:init/2 (src/cache_bucket.erl, line 79)
in call from cache_bucket:init/1 (src/cache_bucket.erl, line 73)
in call from gen_server:init_it/6 (gen_server.erl, line 304)
in call from proc_lib:init_p_do_apply/3 (proc_lib.erl, line 239)
When I add in sys.config i have error too, when start up my App(
And i try add into {env, [{memory, 206870912}]}
in myapp.app.src, but it did not produce the expected effect it to limit memory
Run the following eshell:
1> cache:start_link(c, [{n,10}, {ttl, 60}]).
2> cache:put(c, x, test, 10).
What is the upper bound ttl of x in cache? I thought it should not be more than 16 seconds but somehow x stays there for minutes. Is this a bug?
Hello,
Will be nice if you can provide in a way or other notifications when the key's are removed because of the TTL expired.
Or in case you don’t want to implement this can you please let me know what part of the code is doing the delete of the expired key's.
Silviu
Hello there,
is there a way to store multiple entires in a single key? (Like an ETS duplicate_bag)
My use case would be a list that only contains the N most recently added entries while discarding older ones. Is there a way to do this using this library or would you recommend another one/rolling my own solution?
Thank you for your time!
Hi,
my node down, due to cache started on distrubute nodes, and logs are attached, please have a look!
([email protected])1> 05:12:08.352 [warning] lager_error_logger_h dropped 63 messages in the last second that exceeded the limit of 50 messages/sec
05:12:08.352 [info] global: Name conflict terminating {pswd_cache,<29575.6921.0>}
05:12:08.352 [info] global: Name conflict terminating {sms_cache,<29575.6922.0>}
05:12:08.352 [info] global: Name conflict terminating {user_token_cache,<29575.6923.0>}
05:15:01.117 [error] Received a MNESIA down event, removing on node '[email protected]' all pids of node '[email protected]'
05:23:17.800 [error] Received a MNESIA down event, removing on node '[email protected]' all pids of node '[email protected]'
05:39:32.342 [info] global: Name conflict terminating {pswd_cache,<29575.4243.0>}
05:39:32.342 [info] global: Name conflict terminating {sms_cache,<29575.4244.0>}
05:39:32.342 [info] global: Name conflict terminating {user_token_cache,<29575.4245.0>}
05:39:35.178 [error] Received a MNESIA down event, removing on node '[email protected]' all pids of node '[email protected]'
05:48:52.009 [info] global: Name conflict terminating {pswd_cache,<29575.7284.0>}
05:48:52.009 [info] global: Name conflict terminating {sms_cache,<29575.7285.0>}
05:48:52.009 [info] global: Name conflict terminating {user_token_cache,<29575.7286.0>}
05:49:02.789 [error] Received a MNESIA down event, removing on node '[email protected]' all pids of node '[email protected]'
05:49:57.855 [info] global: Name conflict terminating {pswd_cache,<29575.818.0>}
05:49:57.859 [info] global: Name conflict terminating {sms_cache,<29575.819.0>}
05:49:57.860 [info] global: Name conflict terminating {user_token_cache,<29575.820.0>}
Is there any limitation on the size of the segmentation for optimal performance? I am trying to cache 3GB in a single segment and facing latency during :get operation.
For example,
{ok, _} = cache:start_link(my_cache, [{n, 10}, {ttl, 60}]).
cache:put(my_cache, x, 100, 120).
cache:lookup(my_cache, x)
will return undefined
after about 54 seconds. Is this a bug?
Evaluate a possible use-cases of given policies.
https://en.wikipedia.org/wiki/Cache_replacement_policies
Hello!
Please tell me this is normal behavior of a cache, then that for any wrong address, he destroyed?
23> {ok, _} = cache:start_link(my_cache, [{n, 10}, {ttl, 600}]).
{ok,<0.79.0>}
25> Val11 = cache:get(my_cache, <<"my key">>).
undefined
26> cache:i(my_cache).
[{heap,[90132]},
{expire,[1384955909]},
{size,[0]},
{memory,[307]}]
27> cache:i(my_cache1).
** exception exit: {noproc,{gen_server,call,[my_cache1,i]}}
in function gen_server:call/2 (gen_server.erl, line 180)
28> cache:i(my_cache).
** exception exit: {noproc,{gen_server,call,[my_cache,i]}}
in function gen_server:call/2 (gen_server.erl, line 180)
29> Val11 = cache:get(my_cache, <<"my key">>).
** exception exit: {noproc,
{gen_server,call,[my_cache,{get,<<"my key">>},60000]}}
in function gen_server:call/3 (gen_server.erl, line 188)
30> {ok, _} = cache:start_link(my_cache, [{n, 10}, {ttl, 600}]).
{ok,<0.90.0>}
31> {ok, _} = cache:start_link(my_cache, [{n, 10}, {ttl, 600}]).
** exception error: no match of right hand side value
{error,{already_started,<0.90.0>}}
32> Val11 = cache:get(my_cache, <<"my key">>).
** exception exit: {noproc,
{gen_server,call,[my_cache,{get,<<"my key">>},60000]}}
in function gen_server:call/3 (gen_server.erl, line 188)
33> cache:i(my_cache).
** exception exit: {noproc,{gen_server,call,[my_cache,i]}}
in function gen_server:call/2 (gen_server.erl, line 180)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.