Home Manual Reference Source
import ResourceCache from '@mapcreator/maps4news/src/ResourceCache.js'
public class | source

ResourceCache

Extends:

Unobservable → ResourceCache
this class was deprecated.

Used for caching resources. Requires the resource to have an unique id field

See:

TODO:

  • Add periodic data refreshing while idle, most likely implemented in cache (maybe v1/resource?timestamp=123 where it will give modified records since)

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public
public
public

emitter: *

Method Summary

Public Methods
public

clear(resourceUrl: String)

Clears the cache

public

Collect relevant cached pages

public

Push a page into the cache

public

resolve(resourceUrl: String, cacheToken: String): Array<ResourceBase>

Resolve cache and return indexed data

public

revalidate(resourceUrl: String)

Revalidate all data and delete stale data

public

Update records in the cache manually lazily.

Inherited Summary

From class Unobservable
public get

Overrides the Object.prototype.toString.call(obj) result

Public Constructors

public constructor() source

Public Members

public cacheTime: * source

public dereference: * source

public emitter: * source

Public Methods

public clear(resourceUrl: String) source

Clears the cache

Params:

NameTypeAttributeDescription
resourceUrl String

Resource url

public collectPages(resourceUrl: String, cacheToken: String): Array<PaginatedResourceListing> source

Collect relevant cached pages

Params:

NameTypeAttributeDescription
resourceUrl String

resource url

cacheToken String

Cache token

Return:

Array<PaginatedResourceListing>

Relevant cached pages

See:

public push(page: PaginatedResourceListing) source

Push a page into the cache

Params:

NameTypeAttributeDescription
page PaginatedResourceListing

Data to be cached

public resolve(resourceUrl: String, cacheToken: String): Array<ResourceBase> source

Resolve cache and return indexed data

Params:

NameTypeAttributeDescription
resourceUrl String

Resource url

cacheToken String

Cache token

Return:

Array<ResourceBase>

Indexed relevant data

See:

TODO:

  • add page numbers or range as optional parameter

public revalidate(resourceUrl: String) source

Revalidate all data and delete stale data

Params:

NameTypeAttributeDescription
resourceUrl String

Resource url

public update(rows: ResourceBase | Array<ResourceBase>) source

Update records in the cache manually lazily. Any matching instance found will be updated.

Params:

NameTypeAttributeDescription
rows ResourceBase | Array<ResourceBase>

Data to be updated