esl / ice

Apache License 2.0
2 stars 4 forks source link

use ETS as a cache backend on branch `master' #73

Open horvand opened 9 years ago

lucafavatella commented 9 years ago

Process reads cache, finds neither calc nor value, writes calc. Are all the previous actions performed atomically?

horvand commented 9 years ago

@lucafavatella You mean the ETS version of insert_new/2 and lookup() are not atomic?

lucafavatella commented 9 years ago

@horvand I cannot look into this more at the moment. I remember Ed and I looked at both ETS and Mnesia as backends (I am aware of insert_new) and 2 different versions of the rules of the semantics at direct contact with cache (eval_something).

In the git history you shall find my partial revert of a commit by Ed on the matter.

What I remember off the top of my head at the moment is that unless either OTP was including https://github.com/erlang/otp/pull/387 (or similar) correctness with ETS was not guaranteed.

Caveats:

horvand commented 9 years ago

Introduced a gen_server to serialise inserts. IMHO, this should provide similar guaranteed as the Mnesia version does. However, this means more or less having a global lock on the whole cache for writes.

et4te commented 9 years ago

Do we have ets:take/2 yet? Looks like it has been accepted, also looks like there is a lock there.