The SDMCache component is responsible for storing and accessing OData related objects in the memory of the device.
ISDMCache void clear(); void setSDMODataServiceDocument(ISDMODataServiceDocument serviceDocument); void setSDMODataSchema(ISDMODataSchema schema); void setSDMODataEntry(ISDMODataEntry entry, String collectionId); void setSDMODataEntries(List<ISDMODataEntry> entries, String collectionId); void setSDMODataDocument(ISDMParserDocument document); ISDMODataServiceDocument getSDMODataServiceDocument(); ISDMODataSchema getSDMODataSchema(); ISDMODataEntry getSDMODataEntry(String key); List<ISDMODataEntry> getSDMODataEntries(String collectionId); ISDMParserDocument getSDMODataDocument(String key); List<ISDMODataEntry> searchSDMODataEntries(String searchTerm, String collectionId); void removeSDMODataServiceDocument(); void removeSDMODataSchema(); void removeSDMODataDocument(String key); void removeSDMODataEntries(String collectionId); void removeStoredDocuments(); int getSearchAlgorithm(); void setSearchAlgorithm(int searchAlgorithm); void setEntrySearch(ISDMEntrySearch entrySearch);
For capacity management, SDMCache uses an LRU (least recently used) algorithm that ensures that the most recently used entries will not be removed first because of reaching the maximum capacity. Maximum number of capacity can be set using preference with key: ISDMPreferences.SDM_CACHE_CAPACITY. This setting refers to the maximum number of cached entities per Collection.
SDMCache supports several predefined search algorithms optimized for performance. Application developers can also set their own EntrySearch object in order to use a custom search algorithm.
SDMCache is an implementer of the ISDMPersistable interface, so it can be persisted with the SDMPersistence component (see more at the section about the SDMPersistence component of Android OData SDK).
SDMCache validates the incoming SDMOData documents by matching their references to each other. A single SDMCache object can store only one set of documents (one Service Document with one related Schema with any number of related Entries).
The SDMOData document created by the SDMParser component automatically sets the required references to the related objects. All these references are automatically maintained during persisting or loading the SDMCache using SDMPersistence.
SDMCache depends on the SDMOData specific interfaces of SDMParser, but does not depend on the real implementation of SDMParser.