LocalCacheManager
Available only in NodeJs & React Native
- NodeJs
- Browser
- React Native
Extends
CacheManager
class LocalCacheManager extends CacheManager
Overwritten Constructor
constructor
constructor(directory :string = ``${RNFS.DocumentDirectoryPath}/adsum/cache``): LocalCacheManager
Parameters:
Name | Type | Required | Default | Description |
---|---|---|---|---|
directory | string | No | `${RNFS.DocumentDirectoryPath}/adsum/cache` | The cache directory to save data |
constructor(directory :string = './adsum/cache'): LocalCacheManager
Parameters:
Name | Type | Required | Default | Description |
---|---|---|---|---|
directory | string | No | "./adsum/cache" | The cache directory to save data |
Methods
getLastPublishDate
async getLastPublishDate(siteId: int, options: CacheOptions): Promise<Date|null>
Parameters:
Name | Type | Required | Description |
---|---|---|---|
siteId | int | Yes | |
options | CacheOptions | Yes |
Returns:
The last published date retrieved from the API. It is null if the Published / Draft feature is not enabled.
Type: Promise<Date|null>
needsUpdate
async needsUpdate(siteId: int, options: CacheOptions): Promise<{needsUpdate: true, lastPublishedDate: Date|null, hasCache: boolean, hasInternetConnexion: boolean, lastCacheUpdateDate: null|Date}, Error>)
Parameters:
Name | Type | Required | Description |
---|---|---|---|
siteId | int | Yes | |
options | CacheOptions | Yes |
Returns:
Type: Promise<object, Error>
Find bellow the details of the properties
Name | Type | Description |
---|---|---|
needsUpdate | boolean | |
lastPublishedDate | Date | null | |
hasCache | boolean | |
hasInternetConnexion | boolean | |
lastCacheUpdateDate | boolean |
update
async update(siteId: int, options: CacheOptions): Promise<boolean, Error>)
Parameters:
Name | Type | Required | Description |
---|---|---|---|
siteId | int | Yes | |
options | CacheOptions | Yes |
Returns:
Returns true if succeed, otherwise false if there is an outdated cache that can be used.
Reject if there is no cache and the cache manager was unable to update.
Type: Promise<boolean, Error>