Package Exports
- @songbaek/fifo-map
- @songbaek/fifo-map/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@songbaek/fifo-map) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Fifo-map
Simple FIFO behavior map cache using Map(key,value) and Array(for improving FIFO performance).
If your usecase can be enough with get(read item), put(put item & FIFO manage when size is full), delete(invalidate item on your own),
it will be fast-read choice.
Memory Usage
Caching N items: N Map items, N ~ 2N Array items
(When using delete() frequently, maximum 2N Array items can be created)
Examples:
Init:
const fifoMap = new FifoMap({maxSize: 10000});Get:
fifoMap.get( key )
Get value as key matches. It will return value if key matches, otherwise return undefined.
const value = fifoMap.get( key );Put:
fifoMap.put( key, value )
Put item. If size is full, it deletes item as FIFO and return deleted item as { key, value }, otherwise return undefined.
const oldItem = fifoMap.put( key, value );Delete:
fifoMap.delete( key )
Delete item if exists. It will return { key, value } if key matches, otherwise return undefined.
const deletedItem = fifoMap.delete( key );Clear:
fifoMap.clear()
clear all items.
fifoMap.clear()