This package allows you to cache data in clustered enviroment. This is simply done with master-worker messaging which allows to send data between multiple processes. Cache is then created in master process and every other process will automatically create communication interface for sharing data.
Disclaimer
- This module will not help you to estabilish clustered enviroment
- Both master and workers processes will be sending messages (IPC)
- Race conditions can occur, it is your's responsibily to lock and unlock keys manually
Usage
Simple use
;; ; /* Creating cache in master works the same as in worker. All the magic is happening inside automatically. */; if cluster.isMaster else
Chained use with locks
;; ;; if cluster.isMaster else /* Should print: 0 1 2*/
Current usable functions
(will be extended lately)
Get the key value:
public get<T>(key: string): Promise<T>;
Set the value of key:
public set<T>(key: string, value: T): Promise<boolean>;
Delete key:
public del(key: string): Promise<boolean>;
Locks the key:
public lock(key: string): Promise<void>;
Unlocks the key:
public unlock(key: string): Promise<void>;