@ioki/node-ts-cache-storage-elasticsearch
TypeScript icon, indicating that this package has built-in type declarations

7.0.1 • Public • Published

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 @ioki/node-ts-cache @ioki/node-ts-cache-storage-elasticsearch
import { ElasticSearchStorage } from "@ioki/node-ts-cache-storage-elasticsearch"
import { Cache, CacheContainer } from "@ioki/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"]
    }
}

Package Sidebar

Install

npm i @ioki/node-ts-cache-storage-elasticsearch

Weekly Downloads

0

Version

7.0.1

License

MIT

Unpacked Size

8.45 kB

Total Files

10

Last publish

Collaborators

  • ans82
  • jonasstr
  • chb-ioki