question

chandrasekar.b03_190734 avatar image
chandrasekar.b03_190734 asked Erick Ramirez edited

Will row cache store the data when the data is read for the first time?

In Cassandra, When the data is read for the first time from sstable, will the data be stored in row cache for the immediate access when it is read again?

What happens if the data in row cache is updated or deleted?

cassandra
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

bettina.swynnerton avatar image
bettina.swynnerton answered

Hi,

if row caching is enabled, Cassandra will detect frequently accessed partitions and store rows of data into RAM to limit the cases where it needs to read from disk.

When data is first read from the table, it's a row cache miss, and the row is cached for the next read.

For the next read it's a row cache hit, and the row is read from the cache.

If the row is updated or deleted later, the cache for it will be invalidated.

Here is a great blog with examples, if you want to practice for yourself. It is quite old, but the examples still work and illustrate very well when the row cache is hit. Note that you may have to enable the row cache first in the cassandra.yaml and restart your node (assuming you are working with your own installation of Cassandra).

https://www.datastax.com/blog/2014/05/tuning-row-cache-cassandra-21

I ran through the example to see if it still worked, the table create syntax is not quite right, use this one:

CREATE TABLE status (
    user text, 
    status_id timeuuid, 
    status text, 
    PRIMARY KEY (user, status_id)) 
    WITH CLUSTERING ORDER BY (status_id DESC) 
    AND caching = {'keys':'ALL', 'rows_per_partition':'10'};

But the rest is good.

Hope this answers your questions!

Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.