https://github.com/waridrox/caching-lib
Tested caching library
https://github.com/waridrox/caching-lib
Last synced: 16 days ago
JSON representation
Tested caching library
- Host: GitHub
- URL: https://github.com/waridrox/caching-lib
- Owner: waridrox
- Created: 2022-01-25T08:35:29.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-05-10T16:50:46.000Z (about 4 years ago)
- Last Synced: 2025-11-13T13:34:56.756Z (8 months ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/caching-library
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# caching-library
Implementation of cache managed via eviction policies like FIFO, LRU and LIFO.
* **FIFO**: First In First Out, the first value in the cache is replaced.
* **LRU**: Last Recently Used, the last recently used value cached is replaced.
* **LIFO**: Last In First Out, the last value in the cache is replaced.
## Usage
```js
const Caches = require('caches')
//To create a cache using a specific eviction policy
const lru = new Caches.lru()
const lifo = new Caches.lifo()
const fifo = new Caches.fifo()
```
## Functions
```js
//Methods
get (key) //Get the value from the cache with the specific key
set (key, value) //Sets the key and the value pair in the cache if it doesn't exist
has (key) //checks if the value for the given key exists in the cache
clear() //clears the cache
del(key) //delete the value for the given key
size() //get the size of the cache
keys() //get all the keys that exist in the cache
values() //get all the values that exist in the cache
```
## For Running Tests
```bash
npm test
```