Velo

A high-performance caching library for Deno

Coveralls GitHub release (latest SemVer)

Table of Contents

Introduction

Velo is an in-memory caching library for Deno focusing on high throughput and hit rate. It provides a simple API, multiple cache strategies, and a variety of optional features. For more details, take a look at our examples and browse the documentation.

Features Overview

  • Size-based eviction
  • Multiple cache strategies (LRU, LFU, ARC, SC, W-TinyLFU)
  • Automated loading of entries into the cache
  • Time-based expiration of entries
  • Listener for cache removals (eviction, expiration, overwrite, manual removal)
  • EventEmitter for cache events
  • Collecting cache hit and miss statistics

Usage

  • Install from deno.land/x
import { Velo } from "https://deno.land/x/velo@0.1.6/mod.ts";
  • nest badge
import { Velo } from "https://x.nest.land/velo@0.1.6/mod.ts";

Velo is a builder class to create a cache instance.

const cache = Velo.builder<string, User>()
  .capacity(100_000)
  .ttl(120_000) // 2 minutes
  .events()
  .build();

cache.set("u:1", { id: "1", name: "John Doe" });
cache.set("u:2", { id: "2", name: "Jane Doe" });

cache.get("u:1"); // { id: "1", name: "John Doe" }

For more detailed explanation and usage guides look at the examples.

Performance

Velo is designed to be fast. It utilizes a fixed-capacity doubly-linked list as internal data structure for policy implementations. This list relies on a custom pointer system inspired by the mnemonist lru cache, which employs TypedArrays to circumvent bookkeeping overhead.

Benchmarks

In velo-benchmarks we provide a set of benchmarks to compare the performance of Velo with other caching libraries. Both hit rate and throughput are measured.