2

I'm inserting some data into a Cassandra table(/column family), and I need to generate a unique key. I've decided to use timeuuid for this, as it gives me nice sortability as well as uniqueness. I can use the now() function to generate the timeuuid, as in this CQL code:

insert into uuidtest ( something, else ) values ( now(), 'hola' );

The problem with this technique is that I have no idea what value I just inserted. I need to know this, as I'm going to need to use it later.

How can I retrieve this value at the time that I insert it (as I certainly can't guarantee that nobody else will insert one immediately after me)?

4

1 回答 1

1

您打算使用什么 Cassandra 客户端?我认为使用普通的 cqlsh 不可能做到这一点。但是使用客户端 API 将允许您单独创建一个 timeuuid 值,并将其作为插入语句的一部分与其他值一起提供。

于 2015-03-26T20:31:07.497 回答