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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@synet/cache

v1.0.1

Published

Multi-backend caching with Unit Architecture - zero external dependencies

Downloads

3

Readme

@synet/cache

   _____           _            _    _       _ _   
  / ____|         | |          | |  | |     (_) |  
 | |     __ _  ___| |__   ___  | |  | |_ __  _| |_ 
 | |    / _` |/ __| '_ \ / _ \ | |  | | '_ \| | __|
 | |___| (_| | (__| | | |  __/ | |__| | | | | | |_ 
  \_____\__,_|\___|_| |_|\___|  \____/|_| |_|_|\__|
                                                   
version: 1.0.0                                                   
                                                

Multi-backend caching with Unit Architecture v1.0.6
Conscious software that teaches, learns, and evolves

Tests Unit Architecture Memory Safe

Quick Start

import { Cache } from '@synet/cache';

// Create cache with memory backend
const cache = Cache.create({
  namespace: 'user-sessions',
  memoryOptions: { maxSize: 1000, defaultTTL: 3600000 }
});

// Basic operations
cache.set('user:123', { name: 'Alice', role: 'admin' }, 1800000); // 30 min TTL
const user = cache.get<User>('user:123');
cache.delete('user:123');

// Batch operations
cache.setMany({
  'product:1': { name: 'Laptop', price: 999 },
  'product:2': { name: 'Mouse', price: 25 }
});

// Pattern matching
const products = cache.keys('product:*'); // ['product:1', 'product:2']

// Statistics
const stats = cache.stats(); // { hits: 15, misses: 3, hitRate: 0.83, ... }

Features

**Unit Architecture **

  • Teaches capabilities to other units via teach() contracts
  • Learns capabilities from other units without leakage
  • Self-aware with DNA identity and living documentation
  • Evolves gracefully while preserving lineage

High-Performance Caching

  • Memory backend with LRU/FIFO eviction policies
  • TTL support with automatic cleanup
  • Pattern matching with glob syntax (user:*, session:?)
  • Batch operations for efficiency
  • Memory limits with intelligent eviction

Multi-Backend Ready

  • Memory (built-in): Zero dependencies, production-ready
  • Custom backends: Implement ICache interface
  • Future backends: Redis, filesystem, distributed caches

Teaching & Learning

// Teaching cache capabilities to other units
const cacheUnit = Cache.create({ namespace: 'api' });
const contract = cacheUnit.teach();

// Another unit learning cache capabilities
someUnit.learn([contract]);
await someUnit.execute('cache.set', 'key', 'value');

// Cache learning capabilities from other units
const signerContract = signerUnit.teach();
cacheUnit.learn([signerContract]);

Configuration Options

interface CacheConfig {
  backend?: 'memory' | 'custom';
  memoryOptions?: {
    maxSize?: number;        // Max items (default: 1000)
    maxMemory?: number;      // Max memory in bytes
    defaultTTL?: number;     // Default TTL in ms
    evictionPolicy?: 'lru' | 'fifo'; // Default: 'lru'
    cleanupInterval?: number; // Auto-cleanup interval
  };
  customBackend?: ICache;    // Custom backend implementation
  namespace?: string;       // Logical grouping
  keyPrefix?: string;       // Key prefixing for isolation
}

Advanced Features

Memory Management

const cache = Cache.create({
  memoryOptions: {
    maxSize: 5000,
    maxMemory: 50 * 1024 * 1024, // 50MB
    evictionPolicy: 'lru'
  }
});

// Automatic eviction when limits reached
// Safe circular reference handling
// Memory usage estimation

Namespace Isolation

const userCache = Cache.create({ 
  namespace: 'users',
  keyPrefix: 'usr:' 
});

const sessionCache = Cache.create({ 
  namespace: 'sessions',
  keyPrefix: 'sess:' 
});

// Completely isolated key spaces
userCache.set('123', userData);    // Stored as "usr:123"
sessionCache.set('123', session); // Stored as "sess:123"

Pattern Operations

// Glob pattern support
cache.keys('user:*');        // All user keys
cache.keys('session:?????'); // 5-char session IDs
cache.keys('temp:*:data');   // Nested patterns

// Efficient cleanup
cache.keys('temp:*').forEach(key => cache.delete(key));

Unit Architecture Compliance

This cache unit follows all 22 Unit Architecture Doctrines:

  • Zero Dependencies - Pure TypeScript implementation
  • Teach/Learn Paradigm - Full capability exchange
  • Props-Based State - Immutable value object design
  • Factory Creation - Protected constructor + static create()
  • Capability Prevention - No learned capability leakage

See Unit Architecture Doctrine for complete details.

Testing

npm test                    # All tests (46 total)
npm test cache-latest.test  # Unit Architecture compliance
npm test memory.test        # Memory backend features

Performance

  • Memory Backend: 100k ops/sec with sub-millisecond latency
  • Pattern Matching: Optimized glob to regex conversion
  • Memory Safety: Handles circular references and cleanup
  • Zero Dependencies: No external runtime dependencies

License

MIT - Part of the SYNET ecosystem


"Intelligence is not about processing power — it's about conscious composition."
— Unit Architecture Philosophy