# AutoRecacheReadCRUDRepo

open class AutoRecacheReadCRUDRepo < RegisteredObject , Id >(originalRepo: ReadCRUDRepo < RegisteredObject , Id >, scope: CoroutineScope, kvCache: KeyValueRepo < Id , RegisteredObject > = MapKeyValueRepo(), recacheDelay: Long = 60.seconds.inWholeMilliseconds, actionWrapper: ActionWrapper = ActionWrapper.Direct, idGetter: ( RegisteredObject ) -> Id ) : ReadCRUDRepo < RegisteredObject , Id > , FallbackCacheRepo (source)

#### Inheritors

AutoRecacheCRUDRepo

## Constructors

AutoRecacheReadCRUDRepo
Link copied to clipboard
constructor(originalRepo: ReadCRUDRepo < RegisteredObject , Id >, scope: CoroutineScope, kvCache: KeyValueRepo < Id , RegisteredObject > = MapKeyValueRepo(), recacheDelay: Long = 60.seconds.inWholeMilliseconds, actionWrapper: ActionWrapper = ActionWrapper.Direct, idGetter: ( RegisteredObject ) -> Id )
constructor(originalRepo: ReadCRUDRepo < RegisteredObject , Id >, scope: CoroutineScope, originalCallTimeoutMillis: Long , kvCache: KeyValueRepo < Id , RegisteredObject > = MapKeyValueRepo(), recacheDelay: Long = 60.seconds.inWholeMilliseconds, idGetter: ( RegisteredObject ) -> Id )

## Properties

autoUpdateJob
Link copied to clipboard
val autoUpdateJob : Job

## Functions

asReadKeyValueRepo
Link copied to clipboard
fun < K , V > ReadCRUDRepo < K , V >. asReadKeyValueRepo (): ReadKeyValueFromCRUDRepo < V , K >

Wraps this ReadCRUDRepo as a ReadKeyValueFromCRUDRepo, exposing CRUD IDs as keys and CRUD objects as values in a ReadKeyValueRepo.

cached
Link copied to clipboard
fun < ObjectType , IdType > ReadCRUDRepo < ObjectType , IdType >. cached (kvCache: KVCache < IdType , ObjectType >, locker: SmartRWLocker = SmartRWLocker(), idGetter: ( ObjectType ) -> IdType ): ReadCRUDCacheRepo < ObjectType , IdType >
fun < ObjectType , IdType > ReadCRUDRepo < ObjectType , IdType >. cached (kvCache: KeyValueRepo < IdType , ObjectType >, locker: SmartRWLocker = SmartRWLocker(), idGetter: ( ObjectType ) -> IdType ): FullReadCRUDCacheRepo < ObjectType , IdType >
contains
Link copied to clipboard
open suspend override fun contains (id: Id ): Boolean

Returns true if an object with the given id exists in the repository.

count
Link copied to clipboard
open suspend override fun count (): Long

Returns the total count of objects stored in the repository.

diff
Link copied to clipboard
suspend fun < Id , Registered > ReadCRUDRepo < Registered , Id >. diff (other: Map < Id , Registered >): MapDiff < Id , Registered >

Computes the difference between this ReadCRUDRepo and a map of items. Retrieves all items from the repository and compares them with the provided map.

directlyCached
Link copied to clipboard
fun < ObjectType , IdType > ReadCRUDRepo < ObjectType , IdType >. directlyCached (kvCache: KeyValueRepo < IdType , ObjectType >, locker: SmartRWLocker = SmartRWLocker(), idGetter: ( ObjectType ) -> IdType ): DirectFullReadCRUDCacheRepo < ObjectType , IdType >
getAll
Link copied to clipboard
open suspend override fun getAll (): Map < Id , RegisteredObject >

Returns all objects in the repository as a map of ID to object. Default implementation iterates all pages using getIdsByPagination and getById.

getById
Link copied to clipboard
open suspend override fun getById (id: Id ): RegisteredObject ?

Returns the object associated with the given id, or null if not found.

getByPagination
Link copied to clipboard
open suspend override fun getByPagination (pagination: Pagination ): PaginationResult < RegisteredObject >

Returns a paginated list of all objects in the repository.

getIdsByPagination
Link copied to clipboard
open suspend override fun getIdsByPagination (pagination: Pagination ): PaginationResult < Id >

Returns a paginated list of all IDs in the repository.

invalidate
Link copied to clipboard
open suspend override fun invalidate ()

Invalidates its internal data. It may lead to autoreload of data. In case when repo makes autoreload, it must do loading of data before clear

maxPagePagination
Link copied to clipboard
inline suspend fun ReadCRUDRepo <*, *>. maxPagePagination (): SimplePagination

Creates a pagination starting from the first page with size equal to the total count of items in this ReadCRUDRepo. This effectively creates a single page containing all items.

withMapper
Link copied to clipboard
inline fun < FromKey , FromValue , ToKey , ToValue > ReadCRUDRepo < ToValue , ToKey >. withMapper (mapper: MapperRepo < FromKey , FromValue , ToKey , ToValue >): ReadCRUDRepo < FromValue , FromKey >

Wraps this ReadCRUDRepo with a mapper to expose different key and value types.

inline fun < FromKey , FromValue , ToKey , ToValue > ReadCRUDRepo < ToValue , ToKey >. withMapper (noinline keyFromToTo: suspend FromKey .() -> ToKey = { this as ToKey }, noinline valueFromToTo: suspend FromValue .() -> ToValue = { this as ToValue }, noinline keyToToFrom: suspend ToKey .() -> FromKey = { this as FromKey }, noinline valueToToFrom: suspend ToValue .() -> FromValue = { this as FromValue }): ReadCRUDRepo < FromValue , FromKey >

Wraps this ReadCRUDRepo with custom conversion functions for keys and values.