Class AutoSavingCache.CacheSerializer<K extends CacheKey,V>

java.lang.Object
org.apache.cassandra.cache.AutoSavingCache.CacheSerializer<K,V>
Direct Known Subclasses:
CacheService.CounterCacheSerializer, CacheService.KeyCacheSerializer, CacheService.RowCacheSerializer
Enclosing class:
AutoSavingCache<K extends CacheKey,V>

@NotThreadSafe public abstract static class AutoSavingCache.CacheSerializer<K extends CacheKey,V> extends Object
A base cache serializer that is used to serialize/deserialize a cache to/from disk.

It expects the following lifecycle: Serializations: 1. serialize(CacheKey, DataOutputPlus, ColumnFamilyStore) is called for each key in the cache. 2. serializeMetadata(DataOutputPlus) is called to serialize any metadata. 3. cleanupAfterSerialize() is called to clean up any resources allocated for serialization.

Deserializations: 1. deserializeMetadata(DataInputPlus) is called to deserialize any metadata. 2. deserialize(DataInputPlus) is called for each key in the cache. 3. cleanupAfterDeserialize() is called to clean up any resources allocated for deserialization.

This abstract class provides the default implementation for the metadata serialization/deserialization. The metadata includes a dictionary of column family stores collected during serialization whenever writeCFS(DataOutputPlus, ColumnFamilyStore) or getOrCreateCFSOrdinal(ColumnFamilyStore) are called. When such metadata is deserialized, the implementation of deserialize(DataInputPlus) may use readCFS(DataInputPlus) method to read the ColumnFamilyStore stored with writeCFS(DataOutputPlus, ColumnFamilyStore).