Skip to content
forked from velo-org/velo

Performant Cache implementations for Deno. Supports LRU, LFU, ARC and other caching policies.

License

Notifications You must be signed in to change notification settings

cryptogohan/velo

 
 

Repository files navigation

Velo

Performant caching for Deno

Table of Contents

Introduction

This library aims to bring you in memory caching, while trying to be as performant as possible for a high level language. Several caching policies are supported. Keys can have a timeout (ttl) after which they expire and are deleted from the cache. And the events can be emitted for different cache opterations.

Quick start

With Deno it's very easy to use third party libraries. Just import from one of the following urls.

  • from deno.land/x
import { [cache-name] } from "https://deno.land/x/velo@0.1.4/mod.ts";
  • from nest.land

nest badge

import { [cache-name] } from "https://x.nest.land/velo@0.1.4/mod.ts";

Caches

  • ARC Cache (adaptive-replacement-cache)
  • LFU Cache (least-frequently-used)
  • LRU Cache (least-recently-used)
  • RR Cache (random-replacement)
  • SC Cache (second-chance)
  • SLRU Cache (segmented-least-recently-used)

Usage

All caches share the same set of methods.

import { LRU } from "https://deno.land/x/velo@0.1.4/mod.ts";

const lru = new LRU({ capacity: 5 });

lru.set(1, 1);
lru.get(1);
lru.delete(1);

lru.set(2, 2, 60000); // with ttl

// event
lru.on("expired", (k, v) => {
  console.log(k, v);
});

For more detailed examples take a look at the examples folder.

Contributing

If you want to contribute to the project please read through our contributing guidelines.

Benchmarks

About

Performant Cache implementations for Deno. Supports LRU, LFU, ARC and other caching policies.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 99.5%
  • Other 0.5%