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

@zcodeapp/cache

v0.1.8

Published

Cache for application

Readme

Cache

Cache CI codecov

Overview

The Cache module is a part of the @zcodeapp framework, designed to provide a flexible caching mechanism for applications. It leverages dependency injection and interfaces from the framework to create a versatile and extensible caching system. The module includes a basic MemoryStrategy for caching, but is built to accommodate different caching strategies.

Features

Flexible Caching Strategy The Cache class allows for changing the caching strategy at runtime, providing flexibility in how data is cached.

Memory-Based Caching Includes a default MemoryStrategy for in-memory caching, suitable for scenarios where quick access to data is required and persistence is not a concern.

MD5 Key Transformation Utilizes MD5 hashing for keys, ensuring consistent key formatting and potentially reducing the risk of key collisions.

Simple API Offers a straightforward API with set and get methods for storing and retrieving data.

Logging Integration Integrates with the @zcodeapp/logger for logging activities, aiding in debugging and monitoring.

Installation

Include the Cache class in your TypeScript project:

npm install @zcodeapp/cache

Usage

import { Di } from '@zcodeapp/di';
import { Cache } from '@zcodeapp/cache';

const di = Di.getInstance();
const cache = di.get(Cache);

await cache.set('myKey', 'myValue');

const value = await cache.get('myKey');

API Reference

Cache Class

  • constructor(logger: Logger, cacheStrategy: MemoryStrategy): Initializes the cache with a logger and a caching strategy.
  • changeStrategy(strategy: ICacheStrategy): void: Changes the caching strategy at runtime.
  • async set(key: string, value: string): Promise<void>: Stores a value in the cache.
  • async get(key: string): Promise<string>: Retrieves a value from the cache.

MemoryStrategy Class

  • async set(key: string, value: string): Promise<void>: Stores a value in memory.
  • async get(key: string): Promise<string>: Retrieves a value from memory.

Example

exampleStrategy.ts

import { Injectable } from "@zcodeapp/di";
import { ICacheStrategy } from "@zcodeapp/interfaces";

@Injectable()
export class ExampleStrategy implements ICacheStrategy {
    public async set(key: string, value: string): Promise<void> {
      // your code...
    }

    public async get(key: string): Promise<string> {
      // your code...
    }
}

main.ts

import { Di } from '@zcodeapp/di';
import { Cache } from '@zcodeapp/cache';
import { ExampleStrategy } from 'exampleStrategy';

const di = Di.getInstance();
const cache = di.get(Cache);
cache.changeStrategy(di.get(ExampleStrategy));

await cache.set('myKey', 'myValue');

const value = await cache.get('myKey');

License

This project is licensed under the MIT License - see the LICENSE file for details.