Skip to main content
Deno 2 is finally here 🎉️
Learn more

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@v0.1.3/mod.ts";
  • from nest.land

nest badge

import { [cache-name] } from "https://x.nest.land/velo@0.1.3/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@v0.1.3/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