Reputation: 189
I need to store last-push-date in Cassandra and wondering what the best way is as it is just one column and one row. Please advise.
Upvotes: 0
Views: 365
Reputation: 2430
You can create a table which has a bucket
as partition key.
This way with a constant bucket ID of 0 you can update that value by just INSERT
operations. This is called "upsert" in Cassandra.
CREATE TABLE last_push_date (
bucket INT,
last_push_date DATE,
PRIMARY KEY (bucket)
);
To insert and update the same last_push_date
value you can use just insert commands using bucket 0:
INSERT INTO last_push_date (bucket, last_push_date) VALUES (0, '2017-11-11');
INSERT INTO last_push_date (bucket, last_push_date) VALUES (0, '2017-11-13');
Selecting last_push_date
will return result of last insert:
SELECT * FROM last_push_date WHERE bucket = 0;
bucket | last_push_date
--------+----------------
0 | 2017-11-13
If you want to have another last_push_date
just use another bucket ID.
Upvotes: 1
Reputation: 131
It's a bit unclear what you are really asking for... But i'll give it a shot.
I think you have already answered your question - there is only one column and one row, which won't have any real impact on the way Cassandra operates. In my experience there is not any best specific way of storing this kind of information - Cassandra is made for quickly being able to store data and has internal ways of dealing with consistency and replication.
Upvotes: 0