Zyre-LRU
ZRE enabled decentralised & distributed LRU Cache w/ TTL
Zyre-LRU will spawn multiple LRUs with set
actions syncronized via whisper
or shout
Usage
const ZDB = ;
Peering
// Initialize peersconst db1 = group: "lru1" size: 1024 discoveryPort: 4567 name: "LRU #1" auto: true ;const db2 = group: "lru2" size: 1024 discoveryPort: 4567 name: "LRU #2" auto: true ; // Set Valuedb1;db1; //should return 123 /* set action will propagate to all connected peers */ db2; // should return 123 // Shutdown peers when donedb1;db2;
LRU Commands
const ZDB = ;const cache = group: "lru1" size: 1024 discoveryPort: 4567 name: "LRU #1" auto: true ; cache; //-> Add item to cache (expire in 100ms). cache; //-> 1cache; //-> truecache; //-> Expire in 50ms (instead of 100).cache; //-> Delete item right away.cacheclear; //-> Empty the cache.// You can also use the "refresh" option to automatically reset a keys expiration when accessed.cache;// 50ms latercache; // Resets timer back to 100ms.// And store meta data about values.cache;// Then retrieve it.cache; //-> { custom: 1 }
Acknowledgement
Zyre-LRU is spinoff clone of zyre-nedb using zyre.js and receptacle