Cassandra行级锁定支持,同时由并发用户访问同一行 [英] Cassandra row level locking support while accessing same row by concurrent users

查看:740
本文介绍了Cassandra行级锁定支持,同时由并发用户访问同一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在设计阶段的我们的购物车应用程序,我们正在考虑Cassandra作为库存数据库。多个用户需要能够同时访问库存数据库中的相同产品行。



例如,产品表包含:


productID = 1000,productQuantitiy = 1



productID = 2000,productQuantitiy = 5


产品1000并在购物车中添加产品数量1,其他用户不能选择该产品,直到被第一用户(其更新产品数量为0)丢弃。



<或者,如果第一用户选择产品2000的3,则访问同一产品的其他用户不能选择相同数量的该产品,直到第一用户(其将产品数量更新为2)丢弃了一些。



Cassandra是否为这种情况提供行级锁定支持?

解决方案

Cassandra没有内置支援来锁定 。 Astyanax API提供了食谱,这是常见用例的实现,其中之一,分布式行锁,用于此类锁定。


We are in design phase of our shopping cart application we are considering Cassandra as Inventory database. Multiple users need to be able to access same product row in Inventory DB at same time.

For example a product table containing:

productID =1000, productQuantitiy = 1

productID =2000, productQuantitiy = 5

If first user selects product 1000 and add product quantity 1 in shopping cart, other users should not be able to select this product until it gets discarded by first user (who updates product quantity as 0).

Alternatively if the first user selects 3 of product 2000, other users accessing the same product should not be able to select the same amount of this product until some is discarded by the first user (who updates product quantity as 2).

Does Cassandra provide row level locking support for this kind of scenario ?

解决方案

Cassandra does not have built in support for locking yet. The Astyanax API provides recipes which are implementations for common use cases, one of which, Distributed Row Lock, is for such locking.

这篇关于Cassandra行级锁定支持,同时由并发用户访问同一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆