Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Implements

Index

Constructors

constructor

Properties

Protected cacheCurSizeKey

cacheCurSizeKey: string

Protected config

config: CacheConfig

Methods

Private _decreaseCurSizeInBytes

  • _decreaseCurSizeInBytes(amount: any): Promise<void>

Private _findValidKeys

  • _findValidKeys(): Promise<any[]>

Private _increaseCurSizeInBytes

  • _increaseCurSizeInBytes(amount: any): Promise<void>

Private _isCacheFull

  • _isCacheFull(itemSize: any): Promise<boolean>

Private _isExpired

  • _isExpired(key: any): Promise<boolean>

Private _popOutItems

  • _popOutItems(keys: any, sizeToPop: any): Promise<void>
  • get all the items we have, sort them by their priority, if priority is same, sort them by their last visited time pop out items from the low priority (5 is the lowest)

    Parameters

    • keys: any

      all the keys in this cache

    • sizeToPop: any

      the total size of the items which needed to be poped out

    Returns Promise<void>

Private _refreshItem

  • _refreshItem(item: any, prefixedKey: any): Promise<any>
  • update the visited time if item has been visited

    Parameters

    • item: any

      the item which need to be refreshed

    • prefixedKey: any

      the key of the item

    Returns Promise<any>

    the refreshed item

Private _removeItem

  • _removeItem(prefixedKey: any, size?: any): Promise<void>

Private _setItem

  • _setItem(prefixedKey: any, item: any): Promise<void>

Private _sizeToPop

  • _sizeToPop(itemSize: any): Promise<number>

clear

  • clear(): Promise<void>

configure

createInstance

  • createInstance(config: any): ICache

Protected fillCacheItem

getAllKeys

  • getAllKeys(): Promise<any[]>

getCacheCurSize

  • getCacheCurSize(): Promise<number>

getItem

  • getItem(key: any, options: any): Promise<any>
  • Get item from cache. It will return null if item doesn’t exist or it has been expired. If you specified callback function in the options, then the function will be executed if no such item in the cache and finally put the return value into cache. Please make sure the callback function will return the value you want to put into the cache. The cache will abort output a warning: If the key is invalid If error happened with AsyncStorage

    Parameters

    • key: any

      the key of the item

    • options: any

    Returns Promise<any>

    • return a promise resolves to be the value of the item

getModuleName

  • getModuleName(): string

removeItem

  • removeItem(key: any): Promise<void>
  • remove item from the cache The cache will abort output a warning: If error happened with AsyncStorage

    Parameters

    • key: any

      the key of the item

    Returns Promise<void>

setItem

  • setItem(key: any, value: any, options: any): Promise<void>
  • Set item into cache. You can put number, string, boolean or object. The cache will first check whether has the same key. If it has, it will delete the old item and then put the new item in The cache will pop out items if it is full You can specify the cache item options. The cache will abort and output a warning: If the key is invalid If the size of the item exceeds itemMaxSize. If the value is undefined If incorrect cache item configuration If error happened with browser storage

    Parameters

    • key: any

      the key of the item

    • value: any

      the value of the item

    • options: any

    Returns Promise<void>