-
- All Implemented Interfaces:
-
com.amplitude.android.sessionreplay.storage.GenericStorage
public class PersistentStorage implements GenericStorage
PersistentStorage is a file-based storage implementation
There are a few main components to the storage:
Properties - currentSequenceId, etc
Data - blob of data, this will be store in file storage
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classPersistentStorage.Companion
-
Constructor Summary
Constructors Constructor Description PersistentStorage(Context context, String storagePrefix, String storageKey, Long maxFileSize, String delimiter, SessionReplayLogger logger)
-
Method Summary
Modifier and Type Method Description final Stringget(String key)Stringget(String key, String defaultValue)Get stored value for key Unitset(String key, String value)Set stored value for key Unitremove(String key)Remove value for key StringserializeData(Object data)By default we serialize data to a string using toString(). ObjectdeserializeData(String data)By default we return the data as a string. StringgenerateNextDataBlockUri()By default we generate a new data block URI using the current time. UnitwriteData(Object data)Store generic data with optional callback and identifier UnitwriteDataList(List<Object> data)Write all data at once for performance reasons. StringreadDataBlock(String uri)Read stored data content for given URI, return null if not found List<String>readDataBlockItems(String uri)Read stored data content for given URI split into individual items based on delimiter Return null if not found BooleanclearDataBlock(String uri)Clear stored data for given URI List<String>getDataBlockUris()Get list of stored data URIs StringgetActiveDataBlockUri()Get URI of active data block LonggetDataBlockSize(String uri)Get size of stored data block LonggetDataTotalSize()Total size of all stored data blocks StringstartNewBlock()Close current storage block, start a new onea.k. UnitclearAllDataBlocks()UnitclearAllKeyValues()Unitclear()-
-
Method Detail
-
serializeData
String serializeData(Object data)
By default we serialize data to a string using toString().
This should be overridden by subclasses to provide custom serialization.
-
deserializeData
Object deserializeData(String data)
By default we return the data as a string. (unchanged)
This should be overridden by subclasses to provide custom serialization.
-
generateNextDataBlockUri
String generateNextDataBlockUri()
By default we generate a new data block URI using the current time.
This should be overridden by subclasses to provide custom file naming.
-
writeData
Unit writeData(Object data)
Store generic data with optional callback and identifier
- Parameters:
data- : Data to be stored
-
writeDataList
Unit writeDataList(List<Object> data)
Write all data at once for performance reasons.
-
readDataBlock
String readDataBlock(String uri)
Read stored data content for given URI, return null if not found
-
readDataBlockItems
List<String> readDataBlockItems(String uri)
Read stored data content for given URI split into individual items based on delimiter Return null if not found
-
clearDataBlock
Boolean clearDataBlock(String uri)
Clear stored data for given URI
-
getDataBlockUris
List<String> getDataBlockUris()
Get list of stored data URIs
-
getActiveDataBlockUri
String getActiveDataBlockUri()
Get URI of active data block
-
getDataBlockSize
Long getDataBlockSize(String uri)
Get size of stored data block
-
getDataTotalSize
Long getDataTotalSize()
Total size of all stored data blocks
-
startNewBlock
String startNewBlock()
Close current storage block, start a new one
a.k.a rollover()
-
clearAllDataBlocks
Unit clearAllDataBlocks()
-
clearAllKeyValues
Unit clearAllKeyValues()
-
-
-
-