Skip to content

Latest commit

 

History

History
740 lines (446 loc) · 20.2 KB

File metadata and controls

740 lines (446 loc) · 20.2 KB

@onzag/itemize / Modules / server/cache / Cache

Class: Cache

server/cache.Cache

The cache class that provides all the functionality that is specified for the cache package, the cache is more than what it name implies because it contains redis and it's the same in all the servers

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new Cache(redisClient, databaseConnection, elastic, sensitiveConfig, storageClients, domain, root, initialServerData): Cache

Builds a new cache instance, before the cache is ready it needs to be able to access the listener as well, but due to the fact that the listener depends on the cache as well it is instantiaded by te listener at the same time

Parameters

Name Type Description
redisClient ItemizeRedisClient the redis client that is used for storing values
databaseConnection DatabaseConnection -
elastic ItemizeElasticClient -
sensitiveConfig ISensitiveConfigRawJSONDataType -
storageClients IStorageProvidersObject -
domain string -
root default the root of itemize
initialServerData IServerDataType -

Returns

Cache

Defined in

server/cache.ts:217

Properties

appData

Private appData: IAppDataType

Defined in

server/cache.ts:199


currentlySetting

Private currentlySetting: Object = {}

Index signature

▪ [id: string]: { replacement: any ; valueBeingSet: any }

Defined in

server/cache.ts:200


databaseConnection

Private databaseConnection: DatabaseConnection

Defined in

server/cache.ts:186


domain

Private domain: string

Defined in

server/cache.ts:188


elastic

Private elastic: ItemizeElasticClient

Defined in

server/cache.ts:187


listener

Private listener: Listener

Defined in

server/cache.ts:192


memoryCache

Private memoryCache: Object = {}

Index signature

▪ [key: string]: { value: ISQLTableRowValue }

Defined in

server/cache.ts:194


redisClient

Private redisClient: ItemizeRedisClient

Defined in

server/cache.ts:185


root

Private root: default

Defined in

server/cache.ts:190


sensitiveConfig

Private sensitiveConfig: ISensitiveConfigRawJSONDataType

Defined in

server/cache.ts:193


serverData

Private serverData: IServerDataType

Defined in

server/cache.ts:191


storageClients

Private storageClients: IStorageProvidersObject

Defined in

server/cache.ts:189

Methods

deletePossibleChildrenOf

deletePossibleChildrenOf(itemDefinition, id, version): Promise<void>

Deletes all the possible children that might have been set as parent of the deleted item definition value

Parameters

Name Type
itemDefinition default
id string
version string

Returns

Promise<void>

Defined in

server/cache.ts:2447


forceCacheInto

forceCacheInto(idefTable, id, version, value, ensure): Promise<void>

forces a cached value for a given item definition table in an id and version

Parameters

Name Type Description
idefTable string the item definition table or its qualified name
id string the id
version string the version or null
value ISQLTableRowValue the value to store
ensure boolean if true does not trust the value right away and checks it against the current value last modified signature and will only set it if it's older (newer)

Returns

Promise<void>

Defined in

server/cache.ts:385


getRaw

getRaw<T>(key): Promise<{ value: T }>

Provides a cached value from its identifier

Type parameters

Name
T

Parameters

Name Type Description
key string the identifier

Returns

Promise<{ value: T }>

a promise with the value

Defined in

server/cache.ts:256


getServerData

getServerData(): IServerDataType

Provides the current server data

Returns

IServerDataType

Defined in

server/cache.ts:3318


onChangeInformed

onChangeInformed(itemDefinition, id, version, data?): Promise<void>

This function triggers once the remote listener has detected a change that has been done by another server instance to a value that we are supposedly currently holding in memory

Parameters

Name Type Description
itemDefinition string the item definition qualified name
id string the id of such
version string the version or null
data? ISQLTableRowValue the entire SQL result

Returns

Promise<void>

a void promise when done

Defined in

server/cache.ts:3347


onChangeInformedNoData

onChangeInformedNoData(itemDefinition, id, version): Promise<void>

When a change has been informed from the cluster that other cluster has made but it provides no data about what has changed and it needs to be manually fetched

Parameters

Name Type
itemDefinition string
id string
version string

Returns

Promise<void>

Defined in

server/cache.ts:3416


onServerDataChangeInformed

onServerDataChangeInformed(newData): void

This function is called once new server data was informed by a redis event

Parameters

Name Type Description
newData IServerDataType the new server data that redis is giving

Returns

void

Defined in

server/cache.ts:3326


pokeCache

pokeCache(keyIdentifier): Promise<void>

Resets the expiration clock of a given identifier

Parameters

Name Type Description
keyIdentifier string the identifier

Returns

Promise<void>

Defined in

server/cache.ts:354


requestCopy

requestCopy(item, id, version, options?): Promise<ISQLTableRowValue>

Given an item that needs to be copied it will create a new copy for it with all its files and everything

Parameters

Name Type Description
item string | default the item to copy from
id string the id to copy from
version string the version to copy from
options ICopyOptions some options for side effects as this calls the request creation function

Returns

Promise<ISQLTableRowValue>

Defined in

server/cache.ts:1510


requestCreation

requestCreation(itemDefinition, value, options): Promise<ISQLTableRowValue>

Request the creation of a new item definition value for an specific item definition

Parameters

Name Type Description
itemDefinition default the item definition we refer to
value ISQLTableRowValue | IRQArgs | IRQValue the value to create, the value can be partial
options ICreationOptions options as to create, some options are required

Returns

Promise<ISQLTableRowValue>

Defined in

server/cache.ts:989


requestDelete

requestDelete(item, id, version, options?): Promise<void>

Request the deletition of an item definition value

Parameters

Name Type Description
item string | default the item definition to delete a value for
id string the id to delete for
version string the version to delete for
options IDeleteOptions -

Returns

Promise<void>

Defined in

server/cache.ts:2555


requestListCache

requestListCache(records): Promise<ISQLTableRowValue[]>

TODO Optimize this, right now it retrieves the list one by one Requests a whole list of search results

Parameters

Name Type Description
records IRQSearchRecord[] the records to request for

Returns

Promise<ISQLTableRowValue[]>

a list of whole sql combined table row values

Defined in

server/cache.ts:3307


requestToken

requestToken(id): Promise<string>

Provides a valid token for a given user, you might not really want to use this method unless you are fairly sure as these are permanent tokens for users for their given session id, normally you would use these tokens for redirected logins

Parameters

Name Type Description
id string the user id

Returns

Promise<string>

Defined in

server/cache.ts:3106


requestUpdate

requestUpdate(item, id, version, update, options): Promise<ISQLTableRowValue>

Requests an update for an item definition where new values are set for this existent item definition value, these are taken as instructions and no checks are done on it

Parameters

Name Type Description
item string | default the item definition in question
id string the id to update
version string the version of that id to update
update IRQArgs the update in question (partial values are allowed)
options IUpdateOptions -

Returns

Promise<ISQLTableRowValue>

a total combined table row value that can be converted into rq

Defined in

server/cache.ts:1671


requestValue

requestValue(item, id, version, options?): Promise<ISQLTableRowValue>

Requests a value from the cache

Parameters

Name Type Description
item string | default the item definition or a qualified name
id string the id to request for
version string the version
options Object -
options.doNotEnsure? boolean -
options.forceRefresh? boolean -
options.useMemoryCache? boolean a total opposite of refresh, (do not use together as refresh beats this one) which will use a 1 second memory cache to retrieve values and store them, use this if you think the value might be used consecutively and you don't care about accuraccy that much
options.useMemoryCacheMs? number -

Returns

Promise<ISQLTableRowValue>

a whole sql value that can be converted into rq if necessary

Defined in

server/cache.ts:3139


setAppData

setAppData(appData): void

Allows to set the app data in the server side where this app is contained

Parameters

Name Type Description
appData IAppDataType the app data

Returns

void

Defined in

server/cache.ts:3425


setListener

setListener(listener): void

Sets the listener for the remote interaction with the clients that are connected, this listener is what informs the client of updates the listener is highly related to the cache as it uses pubsub that comes from redis

Parameters

Name Type Description
listener Listener the listener

Returns

void

Defined in

server/cache.ts:247


setRaw

setRaw(key, value, onConflict): Promise<void>

Parameters

Name Type
key string
value any
onConflict (value: any) => boolean

Returns

Promise<void>

Defined in

server/cache.ts:301


triggerSearchListenersFor

triggerSearchListenersFor(itemDefinition, createdBy, newParent, originalParent, propertyMap, record, location): void

Parameters

Name Type
itemDefinition default
createdBy string
newParent Object
newParent.id string
newParent.type string
newParent.version string
originalParent Object
originalParent.id string
originalParent.type string
originalParent.version string
propertyMap IPropertyMapElement[]
record IRQSearchRecord
location "modified" | "new" | "deleted"

Returns

void

Defined in

server/cache.ts:459


updatePointerMap

updatePointerMap(transactingDatabase, itemDefinition, id, version, pointerMap): Promise<ItemizeRawDB>

Parameters

Name Type
transactingDatabase DatabaseConnection
itemDefinition default
id string
version string
pointerMap IPropertyMapElementPointer[]

Returns

Promise<ItemizeRawDB>

Defined in

server/cache.ts:3429


wipe

wipe(): Promise<void>

wipes the cache, usually executed on edge cases during connectivity issues with clusters and nodes, once the connection is restablished with redis the cache is wiped by the cluster manager which handles the cache

Returns

Promise<void>

Defined in

server/cache.ts:3396