https://github.com/saiteja-madha/fixedsize-map
📦 A simple in-memory cache that can hold a fixed number of key value pairs
https://github.com/saiteja-madha/fixedsize-map
Last synced: 8 days ago
JSON representation
📦 A simple in-memory cache that can hold a fixed number of key value pairs
- Host: GitHub
- URL: https://github.com/saiteja-madha/fixedsize-map
- Owner: saiteja-madha
- Created: 2021-09-19T14:43:16.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-03-25T08:41:49.000Z (about 1 year ago)
- Last Synced: 2024-05-01T17:37:24.600Z (about 1 year ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/fixedsize-map
- Size: 11.7 KB
- Stars: 0
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## About
**Fixed Size Map** is a Javascript implementation of Map to hold a limited number of keys
## Advantages
- Simple to use cache
- Lightweight## Installation
```
npm i fixedsize-map
```## Usage
```js
const FixedSizeMap = require("fixedsize-map");const cache = new FixedSizeMap(100);
// Adding elements to cache
cache.add("k1", "Some Value");
cache.add("k2", "Some Value");
```## Available Methods
| Method | Description |
| ------------- | ------------------------------------------------------------------------------ |
| `add(k, v)` | Adds a key and pairs it with a value |
| `contains(k)` | Checks if this cache contains a key |
| `get(k)` | Retrieves a value from this cache corresponding to the specified key |
| `remove(k)` | Removed the key value entry from this cache corresponding to the specified key |
| `clear()` | Clears the cache |