Memcached, Locking and Race Conditions

前端 未结 4 1170
心在旅途
心在旅途 2021-02-02 13:14

We are trying to update memcached objects when we write to the database to avoid having to read them from database after inserts/updates.

For our forum post object we ha

4条回答
  •  攒了一身酷
    2021-02-02 13:40

    memcached operations are atomic. the server process will queue the requests and serve each one completely before going to the next, so there's no need for locking.

    edit: memcached has an increment command, which is atomic. You just have to store the counter as a separate value in the cache.

提交回复
热议问题