6.0.1 • Published 2 years ago
@boredland/node-ts-cache-storage-elasticsearch v6.0.1
node-ts-cache-storage-elasticsearch
ElasticSearch storage module for node-ts-cache.
This module expects you to bring your own instance of ElasticSearch.
yarn add @boredland/node-ts-cache @boredland/node-ts-cache-storage-elasticsearch
import { ElasticSearchStorage } from "@boredland/node-ts-cache-storage-elasticsearch"
import { Cache, CacheContainer } from "@boredland/node-ts-cache"
import { Client } from "@elastic/elasticsearch";
const client = new Client({
node: "http://localhost:9200",
Connection: mock.getConnection(),
});
const storage = new ElasticSearchStorage(indexName, client);
const userCache = new CacheContainer(storage)
class MyService {
@Cache(userCache, { ttl: 60 })
public async getUsers(): Promise<string[]> {
return ["Max", "User"]
}
}