Add Elasticsearch and Memcached storage adapters #14
+1,589
−52
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.