FileCacheManager

class FileCacheManager(context: Context, filePath: String, perFileSizeThreshold: Int = 15000) : InMemoryCacheManager

File cache manager: Class that stores events to the file system in disk

Purpose of the class: Keep synced with memory

eventToFileIdMap - Each event with unique event id is mapped to file id (unique name of the file)

uniqueFileId - Unique Id of the file (or name of the file) in which events are pushed

All the file operations are running in the background thread

Any operation failure invoke moveInMemoryDataToFile as a fallback which cleans all the disk and re sync

Constructors

Link copied to clipboard
constructor(context: Context, filePath: String, perFileSizeThreshold: Int = 15000)

Functions

Link copied to clipboard
open override fun add(event: Event): Boolean

Add Single event to the memory and then add to the file

Link copied to clipboard
open override fun addAll(eventList: List<Event>): Boolean

Add List of events to the memory and then add to file

Link copied to clipboard
open override fun getEvents(status: List<EventStatus>): List<Event>

Get List of events from the memory based on the status

Link copied to clipboard
open override fun getEventSize(status: List<EventStatus>): Int

Get count of events in memory based on the status

Link copied to clipboard
open override fun getEventSizeInBytes(status: List<EventStatus>): Int

Get size of events in memory in bytes based on the status

Link copied to clipboard
open override fun remove(event: Event): Boolean

Remove single event from the memory and then remove from the file

Link copied to clipboard
open override fun removeAll(status: List<EventStatus>): Boolean

Remove list of events from the memory based on the status and then remove from the file

Link copied to clipboard
open override fun syncDataFromCache(success: (Boolean, List<Event>) -> Unit)

Fetch events from the disk

Link copied to clipboard
open override fun syncDataToCache(success: (Boolean) -> Unit)

Fetch in memory events and push all the events to disk

Link copied to clipboard
open override fun updateEventStatus(event: Event, status: EventStatus): Boolean

Update status for the event to the memory and then to the file

Link copied to clipboard
open override fun updateEventStatusAll(eventList: List<Event>, status: EventStatus): Boolean

Update status for the list of events to the memory and then to the file