Skip to content

Conversation

@simllll
Copy link
Owner

@simllll simllll commented Jan 22, 2026

Summary

This PR adds two new storage adapter packages to the node-ts-cache monorepo: Elasticsearch and Memcached. These adapters extend the caching capabilities to support additional distributed caching backends commonly used in production environments.

Key Changes

  • New Package: @node-ts-cache/elasticsearch-storage

    • Implements ElasticsearchStorage class for caching via Elasticsearch indices
    • Supports both pre-configured client instances and client options
    • Includes comprehensive test suite with Docker setup instructions
    • Handles 404 errors gracefully for non-existent documents
  • New Package: @node-ts-cache/memcached-storage

    • Implements MemcachedStorage class for distributed Memcached caching
    • Supports single and multiple server configurations
    • Includes configurable options for retries, timeout, and pool size
    • Comprehensive test suite with Docker setup instructions
  • Documentation Updates

    • Updated README.md with new storage adapters in comparison tables
    • Updated architecture diagram to include Elasticsearch and Memcached
    • Added storage selection guide with new adapters
    • Updated ADVANCED.md with detailed usage examples for both new adapters
    • Updated ts-cache/README.md storage comparison table
  • Dependency Management

    • Added @elastic/elasticsearch (^8.17.0) for Elasticsearch support
    • Added memcached (^2.2.2) for Memcached support
    • Added @types/memcached (^2.2.10) for TypeScript support
    • Updated pnpm-lock.yaml with all transitive dependencies

Implementation Details

Both adapters implement the IAsynchronousCacheType interface:

  • getItem<T>(key): Retrieves cached values with proper type support
  • setItem<T>(key, content): Stores values with automatic serialization
  • clear(): Clears all cached data
  • Proper error handling and graceful degradation

The Elasticsearch adapter uses document-based storage with automatic refresh, while the Memcached adapter uses JSON serialization for complex objects and supports distributed caching across multiple servers.

Add a new @node-ts-cache/elasticsearch-storage package that provides
an Elasticsearch-based storage backend for caching. The implementation
uses the @elastic/elasticsearch v8 client and supports:

- Basic get/set/clear operations via IAsynchronousCacheType interface
- Pre-configured client injection for advanced use cases
- Automatic document cleanup with refresh-wait semantics
Add a new @node-ts-cache/memcached-storage package that provides
a Memcached-based storage backend for high-performance distributed
caching. The implementation uses the memcached package and supports:

- Basic get/set/clear operations via IAsynchronousCacheType interface
- Single server or multi-server distributed configuration
- Configurable connection options (retries, timeout, poolSize)

Also updates all documentation to include both Elasticsearch and
Memcached storage adapters in:
- Main README.md (packages table, architecture diagram, choosing guide)
- ts-cache/README.md (storage engines table)
- ts-cache/ADVANCED.md (detailed configuration examples)
@changeset-bot
Copy link

changeset-bot bot commented Jan 22, 2026

🦋 Changeset detected

Latest commit: d096481

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
@node-ts-cache/core Patch
@node-ts-cache/elasticsearch-storage Patch
@node-ts-cache/memcached-storage Patch
@node-ts-cache/valkey-storage Patch
@node-ts-cache/lru-redis-storage Patch
@node-ts-cache/lru-storage Patch
@node-ts-cache/redis-storage Patch
@node-ts-cache/ioredis-storage Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

claude and others added 3 commits January 22, 2026 21:16
Add a new @node-ts-cache/valkey-storage package that provides
a Valkey-based storage backend. Valkey is the open-source,
Redis-compatible fork backed by the Linux Foundation.

Features:
- Basic get/set/clear operations via IAsynchronousCacheType interface
- Batch operations via IMultiIAsynchronousCacheType interface
- Configurable TTL with maxAge option
- Error handler support for non-blocking writes
- Uses iovalkey client (ioredis-compatible)

Also updates all documentation to include Valkey storage adapter in:
- Main README.md (packages table, architecture diagram, choosing guide)
- ts-cache/README.md (storage engines table)
- ts-cache/ADVANCED.md (detailed configuration examples)
This changeset introduces patch versions for the core and storage adapters, including Elasticsearch and Memcached.
Update tests for Elasticsearch, Memcached, and Redis storage adapters
to use mock clients instead of requiring real service connections.
This allows tests to run in CI without needing external services.

Changes:
- Elasticsearch: Add MockElasticsearchClient class for testing
- Memcached: Add client injection support and MockMemcached class
- Redis: Add client injection support and MockRedisClient class

All adapters now accept a pre-configured client in their options,
which enables easy mocking for tests while maintaining backward
compatibility for production use.
@simllll simllll merged commit 49b7540 into main Jan 22, 2026
5 checks passed
@simllll simllll deleted the claude/add-elasticsearch-storage-plugin-lwtjT branch January 22, 2026 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants