代码之家  ›  专栏  ›  技术社区  ›  Tanvi

Cassandra中的更新不是反模式吗?

  •  5
  • Tanvi  · 技术社区  · 7 年前

    每当我们在CQLSH中使用UPDATE或使用Datastax驱动程序设置一些列(使用IFs和集合更新)时,它不是先读后写吗?这不是反模式吗?我错过什么了吗?

    P、 我说的不仅仅是更新,而是对特定专栏的更新。

    TIA!

    1 回复  |  直到 7 年前
        1
  •  5
  •   Ashraful Islam    7 年前

    不,更新不是反模式。

    在Cassandra中,update是一种类似于insert的upsert操作。

    但是 Lightweight transactions

    轻量级事务示例:

    #Lightweight transaction Insert
    INSERT INTO customer_account (customerID, customer_email) 
    VALUES (‘LauraS’, ‘lauras@gmail.com’)
    IF NOT EXISTS;
    
    #Lightweight transaction Update
    UPDATE customer_account
    SET    customer_email=’laurass@gmail.com’
    IF     customerID=’LauraS’; 
    

    上述两种语句都是轻量级事务

    资料来源: http://docs.datastax.com/en/cql/3.3/cql/cql_reference/cqlUpdate.html#cqlUpdate__description