npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@solumjs/cache

v0.3.5

Published

SolumJS cache: Cacheable/CacheEvict decorators with in-memory or Redis backend

Readme

@solumjs/cache

Caching with decorator-based cache management. InMemory and Redis cache stores.

Install

npm install @solumjs/cache

Cache Decorators

import { Cacheable, CacheEvict, CachePut, CacheManager } from "@solumjs/cache";
import { Bean } from "@solumjs/core";

@Bean("IProductService")
export class ProductService {

    @Cacheable("products", 300, "{id}")
    async findById(id: string): Promise<Product> {
        // Only executed if not in cache
        return this.productRepo.findById(id);
    }

    @CachePut("products", 300, "{id}")
    async update(id: string, dto: UpdateProductDto): Promise<Product> {
        // Always executes and updates cache
        return this.productRepo.update(id, dto);
    }

    @CacheEvict("products")
    async delete(id: string): Promise<void> {
        await this.productRepo.delete(id);
    }
}

Decorator Signatures

Cacheable(cacheName: string, ttlSeconds?: number, keyExpression?: string)
CachePut(cacheName: string, ttlSeconds?: number, keyExpression?: string)
CacheEvict(cacheName: string)

Cache Key Expression

// Named params resolved from method arguments
@Cacheable("users", 60, "{id}")
async findById(id: string) { /* ... */ }

// Positional syntax
@Cacheable("orders", 60, "{0}:item:{1}")
async getOrderItem(orderId: string, itemId: string) { /* ... */ }

CacheManager

import { cacheManager } from "@solumjs/cache";

// Get from cache
const value = await cacheManager.get("key");

// Set cache
await cacheManager.set("key", value, 60);

// Evict by prefix
await cacheManager.evict("users");

// Sweep expired entries
const removed = await cacheManager.sweep();

// Clear all
await cacheManager.clear();

InMemoryCacheStore

import { InMemoryCacheStore } from "@solumjs/cache";

// Default: 10000 entries
const store = new InMemoryCacheStore();

// Custom max entries
const store = new InMemoryCacheStore(5000);

RedisCacheStore

import { RedisCacheStore, connectRedis } from "@solumjs/cache";

const client = await connectRedis("redis://localhost:6379");
const store = new RedisCacheStore(client);

// Set as default store
cacheManager.useStore(store);

resolveCacheKey

import { resolveCacheKey } from "@solumjs/cache";

const key = resolveCacheKey("{id}", ["123"]);
// "123"

const key = resolveCacheKey("{0}:item:{1}", ["order-1", "item-2"]);
// "order-1:item-2"

Disposable Cache Entries (ES2026 using)

Auto-evicting cache entries using ES2026 Explicit Resource Management.

import { DisposableCacheEntry, AsyncDisposableCacheEntry, cacheManager } from "@solumjs/cache";

// Sync disposable - auto-evicts when leaving scope
{
    using entry = new DisposableCacheEntry(cacheManager, "temp:data", { foo: "bar" }, 300);
    console.log(entry.value); // { foo: "bar" }
    // automatically evicted when leaving this block
}

// Async disposable - for async contexts
async function handleRequest() {
    await using entry = new AsyncDisposableCacheEntry(cacheManager, "session:abc", sessionData, 600);
    // entry.value is sessionData
    // automatically evicted when leaving this async function
}

License

MIT