Database Reference
In-Depth Information
If you have caching enabled in cassandra.yaml , Cassandra automatically caches data
based on frequency of its access and size of the data. You can tune it for individual tables
if you want. All you need to do is to specify caching in table creation or update CQL.
There are two types of caching: row caching, which is similar to the caching that object-
relational mappers provide on top of RDBMS. Row caching caches the whole row and re-
turns it from the memory if it is cached. The data gets cached after its first access. The
other type of caching is key caching where just the key is cached in the memory. It takes
much smaller memory, so we can have lots of keys caches without burning a lot of
memory. Unlike row caching, this does require a disk seek to read the actual data. But
data retrieval is much more efficient with key caching enabled than without it. It is sug-
gested to keep key caching on unless you have a specific reason not to.
If you are using Cassandra 2.1, you can set both the caching individually using the follow-
ing property:
caching = { 'keys' : '{NONE|ALL}', 'rows_per_partition' :
'{NONE|ALL|positive_int}' };
Here's an example:
CREATE TABLE searched_pages (
page_id uuid,
page_text text,
metadata text,
advertisement_count int,
PRIMARY KEY (page_id)
) WITH caching = { 'keys' : 'ALL', 'rows_per_partition' :
'31415' };
For Cassandra 2.0.x releases, the query looks a bit different. You specify it as caching
= {'all'|'keys_only'|'rows_only'|'none'} .
Here's an example:
CREATE TABLE searched_pages (
page_id uuid,
page_text text,
metadata text,
advertisement_count int,
Search WWH ::




Custom Search