#4 Why mmcache_lock?

closed
nobody
None
5
2003-10-27
2003-10-25
Anonymous
No

Hi,

could you please explain why and when I need
mmcache_lock?

It is obiously an optional function and not
directly implemented in mmcache_put, so it
is probably not absolutely neccessary.

Could you please give me a scenario where
I have to use mmcache_lock?

What are the disadvantages of mmcache_lock?
(when there were no disadvantages you had
implemented it directly in mmcache_put...)

Thank you!!!

Discussion

  • Dmitry Stogov

    Dmitry Stogov - 2003-10-27

    Logged In: YES
    user_id=124551

    mmcache_get() and mmcache_put() does locking for short
    time while they update shared memory, but not between
    different calls.

    The following example must increment counter:

    mmcache_put("c",mmcahce_get("c")+1);

    But it this script will accessed by several concurent processes
    it can lose some hits, because there is not locking between
    mmcache_get and mcache_put.
    mmcache_lock/mmcache_unlock were implemented to avoid
    this problem:

    mmcache_lock("lock");
    mmcache_put("c",mmcahce_get("c")+1);
    mmcache_unlock("lock");

     
  • Dmitry Stogov

    Dmitry Stogov - 2003-10-27
    • status: open --> closed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks