Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
node-cache-engine
Advanced tools
High performing cache library (with cache replacement) for browser and node
Simple and High performing cache engine package for node/javascript. It using default cache replacement is LRU (Least Recently Used) cache engine and hash table as javascript Map Object.
npm install --save node-cache-engine
import { createCache } from 'node-cache-engine';
const cache = createCache(); // creating instance of cache with default configuration
cache.add('key', 'value'); // add into cache
cache.get('key'); // get from cache
cache.has('key'); // checking from key is existing in cache
cache.remove('key'); // removing from cache
cache.size(); // get the size of cache
import { createCache } from 'node-cache-engine';
const cache = createCache({
size: 100, // Maximum size for the cache. default value is Number.MAX_SAFE_INTEGER
engine: 'LRU', // cache replacement engine default is LRU (Least Recently Used)
HashTable: YourCustomHashTable, // for custom hash Table. default hashTable is 'src/dataStructure/HashTable.js'
});
Engines Name | key | supported options |
---|---|---|
Least Recently Used | LRU | HashTable, size |
Least Frequently Used | LFU | HashTable, size |
Engine | Method | Time complexity |
---|---|---|
LRU/LFU | add | O(1) |
get | O(1) | |
has | O(1) | |
remove | O(1) | |
size | O(1) |
Methods | LRU | LFU |
---|---|---|
add | ✅ | ✅ |
get | ✅ | ✅ |
has | ✅ | ✅ |
remove | ✅ | ✅ |
size | ✅ | ✅ |
clearAll | ✅ | ❌ |
toArray | ✅ | ❌ |
When and Why you should create custom hash table?
The default hash table implemented with Map
. If you want much more performance than default you can implement your own (like node wrapped c++ hash table). I think 1 to 5 million cache entry default hash table is fine if your use case is more than this go for custom hash table.
To implement custom hashTable you have to use methods with symbols name provided from the package. example
Contributions to this project are always welcome.
Please read CONTRIBUTING.md for a How-to.
[2.0.3] - 2024-05-13
FAQs
High performing cache library (with cache replacement) for browser and node
The npm package node-cache-engine receives a total of 149 weekly downloads. As such, node-cache-engine popularity was classified as not popular.
We found that node-cache-engine demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.