Add Elasticsearch and Memcached storage adapters#14
Merged
Conversation
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 detectedLatest commit: d096481 The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 packages
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 |
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
ElasticsearchStorageclass for caching via Elasticsearch indicesNew Package: @node-ts-cache/memcached-storage
MemcachedStorageclass for distributed Memcached cachingDocumentation Updates
Dependency Management
@elastic/elasticsearch(^8.17.0) for Elasticsearch supportmemcached(^2.2.2) for Memcached support@types/memcached(^2.2.10) for TypeScript supportImplementation Details
Both adapters implement the
IAsynchronousCacheTypeinterface:getItem<T>(key): Retrieves cached values with proper type supportsetItem<T>(key, content): Stores values with automatic serializationclear(): Clears all cached dataThe 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.