ResourceCache
Extends:
Used for caching resources. Requires the resource to have an unique id field
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 |
cacheTime: * |
|
public |
dereference: * |
|
public |
emitter: * |
Method Summary
Public Methods | ||
public |
Clears the cache |
|
public |
collectPages(resourceUrl: String, cacheToken: String): Array<PaginatedResourceListing> Collect relevant cached pages |
|
public |
push(page: PaginatedResourceListing) 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(rows: ResourceBase | Array<ResourceBase>) Update records in the cache manually lazily. |
Inherited Summary
From class Unobservable | ||
public get |
Overrides the |
Public Constructors
public constructor() source
Public Methods
public clear(resourceUrl: String) source
Clears the cache
Params:
Name | Type | Attribute | Description |
resourceUrl | String | Resource url |
public collectPages(resourceUrl: String, cacheToken: String): Array<PaginatedResourceListing> source
Collect relevant cached pages
public push(page: PaginatedResourceListing) source
Push a page into the cache
Params:
Name | Type | Attribute | Description |
page | PaginatedResourceListing | Data to be cached |
public resolve(resourceUrl: String, cacheToken: String): Array<ResourceBase> source
Resolve cache and return indexed data
TODO:
- add page numbers or range as optional parameter
public revalidate(resourceUrl: String) source
Revalidate all data and delete stale data
Params:
Name | Type | Attribute | Description |
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:
Name | Type | Attribute | Description |
rows | ResourceBase | Array<ResourceBase> | Data to be updated |