# @sylo-digital/kas

> Flexible caching solution - with robust, built-in TypeScript types.

Latest version **2.2.0** (published 2026-11-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install @sylo-digital/kas
pnpm add @sylo-digital/kas
yarn add @sylo-digital/kas
bun add @sylo-digital/kas
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.2.0 |
| Published | 2026-11-19 |
| First published | 2021-05-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=22 |
| Dependencies | 0 |
| Unpacked size | 377.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Maintainers | cykreet, ryanke |
| Keywords | cache, key value, memory, redis, set |

## Links

- npm: https://www.npmjs.com/package/@sylo-digital/kas
- Repository: github:sylo-digital/kas
- npm.io page: https://npm.io/package/@sylo-digital/kas

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 2.2.0 (latest) — 2026-11-19
- 2.1.2 — 2023-08-25
- 2.1.1 — 2023-08-25
- 2.1.0 — 2023-08-25
- 2.0.1 — 2023-07-19
- 2.0.0 — 2023-07-19
- 1.0.0 — 2023-05-29
- 0.8.6 — 2022-04-26
- 0.8.5 — 2022-03-25
- 0.8.4 — 2021-12-10
- 0.8.3 — 2021-12-10
- 0.8.2 — 2021-12-09
- 0.7.12 — 2021-10-31
- 0.7.10 — 2021-10-16
- 0.7.6 — 2021-07-31
- … 9 more at https://npm.io/package/@sylo-digital/kas/versions

## README

# sylo-digital/kas

Flexible caching solution -- with robust, built-in TypeScript types and Redis support.

## Features

- Redis (sets) support, with namespace support -- scope entries to a "namespace" to avoid collisions with similarly named keys.
- Generic classes, providing sweet type safety.
- String-based TTLs (although a raw milliseconds value is supported if you want that extra performance, supported with an exported `Duration` enum with some pre-calculated durations)

## Usage

```ts
import { MemoryMapCache } from "@sylo-digital/kas";

// instansiate memory map cache with default ttl of 5 seconds,
// this ttl is then applied to all entries.
const cache = new MemoryMapCache<string>("5s");
cache.set("foo", "bar");
cache.set("fortnite", "epic", "1 minute"); // entry-specific ttl

cache.get("foo"); // "bar"
cache.get("fortnite"); // "epic"
```

### Redis Cache

Redis caches can be instantiated like any Redis instance.

```ts
import { Redis } from "ioredis";
import { connectionOptions } from "./constants";
import { RedisMapCache } from "@sylo-digital/kas";

const cache = new RedisMapCache<string>(connectionOptions, "namespace", "5s");
const cache = new RedisMapCache<string>(process.env.REDIS_URI, "namespace", 5000);

// use redis instance directly.
const redis = new Redis(connectionOptions);
const cache = new RedisMapCache<string>(redis, "namespace", { defaultExpiry: "5s" });

// although the set cache class has a "defaultExpiry" option,
// expiry isn't currently supported, but might be a thing in the future.
const set = new RedisSetCache<string>(redis, "namespace");
```

---
_Source: https://npm.io/package/@sylo-digital/kas · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
