在NoSQL中,先写后读是什么? [英] What's read-before-write in NoSQL?

查看:126
本文介绍了在NoSQL中,先写后读是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读过一本书: Cassandra是NoSQL数据库,它提倡先写后读,而不是关系模型。

I read in a book : "Cassandra is an NoSQL database and promotes read-before-write instead of relational model".

read-before-

What does "read-before-write" means in a NoSQL context?

推荐答案

在写之前读意味着在修改单元格之前要检查它的值。

Read before write means that you are checking the value of a cell before modifying it.

在Cassandra中,先写后读是一种巨大的反模式。您所读的任何鼓励这样做的书都应该引起怀疑。通常,执行Cassandra写操作时不会获取有关数据库当前状态的任何信息。这样做的副作用之一是,对Cassandra的所有写入实际上都是更新操作。

Read-Before write is a huge anti-pattern in Cassandra. Any book you read that encourages doing this should be looked at with suspicion. Normally Cassandra writes are performed without having any information about the current state of the database. One of the side effects of this is that all writes to Cassandra are actually update operations. This is allows for extremely fast writes but does have some limitations.

如果确实需要在写之前检查数据库的状态,Cassandra提供了 Check and Set(检查并设置)( CAS)操作,该操作在修改记录之前使用PAXOS建立数据库状态。它们的写法类似于更新表集x = 3(如果y = 1 )。 CAS查询比C *中的普通写入要慢几个数量级,应谨慎使用。

If you really need to check the state of the database before writing, Cassandra provides "Check and Set"(CAS) operations which use PAXOS to establish database state prior to modifying the record. These are written like update table set x = 3 if y = 1. CAS queries are orders of magnitude slower than a normal write in C* and should be used sparingly.

这篇关于在NoSQL中,先写后读是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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