https://github.com/velo-org/velo
A high-performance caching library for Deno. Supports LRU, LFU, ARC, and TinyLFU.
https://github.com/velo-org/velo
cache caching deno typescript
Last synced: 4 months ago
JSON representation
A high-performance caching library for Deno. Supports LRU, LFU, ARC, and TinyLFU.
- Host: GitHub
- URL: https://github.com/velo-org/velo
- Owner: velo-org
- License: mit
- Created: 2020-07-08T19:09:02.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-11-16T21:20:23.000Z (over 3 years ago)
- Last Synced: 2025-10-20T20:36:17.027Z (8 months ago)
- Topics: cache, caching, deno, typescript
- Language: TypeScript
- Homepage:
- Size: 417 KB
- Stars: 13
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README

Velo
A high-performance caching library for Deno
## Table of Contents
- [Introduction](#introduction)
- [Usage](#usage)
- [Features Overview](#features-overview)
- [Performance](#performance)
## 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](./examples/) and browse the [documentation](https://doc.deno.land/https/deno.land/x/velo@0.1.6/mod.ts).
## 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`
```ts
import { Velo } from "https://deno.land/x/velo@1.0.0/mod.ts";
```
- [](https://nest.land/package/velo)
```ts
import { Velo } from "https://x.nest.land/velo@1.0.0/mod.ts";
```
`Velo` is a builder class to create a cache instance.
```ts
const cache = Velo.builder()
.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](./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](https://github.com/Yomguithereal/mnemonist/blob/master/lru-cache.js), which employs TypedArrays to circumvent bookkeeping overhead.
### Benchmarks
In [velo-benchmarks](https://github.com/velo-org/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.