Socket
Socket
Sign inDemoInstall

solr-client-cache

Package Overview
Dependencies
21
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

solr-client-cache

Caching for Solr Client


Version published
Maintainers
1
Weekly downloads
1

Weekly downloads

Readme

Source

solr-client-cache

Caching module for solr-client using cacheman.

Installation

This module is distributed using npm which comes bundled with node:

npm install --save solr-client-cache

Usage

const solr = require('solr-client');
const solrCache = require('solr-client-cache');

const client = solr.createClient();

solrCache(client, {
  ttl: 60,
  engine: 'redis',
  host: '127.0.0.1',
  port: 6379
});

// search Solr with cache
client
  .cache()
  .search(query, (err, results) => { /* ... */ });

// search Solr without cache
client
  .search(query, (err, results) => { /* ... */ });

If you want a different TTL (Time to Live) for a specific query, then pass it to the cache() function.

const solr = require('solr-client');
const solrCache = require('solr-client-cache');

const client = solr.createClient();

solrCache(client, { ttl: 60 });

// search Solr with cache
client
  .cache(10) // 10 seconds TTL instead of 60s
  .search(query, (err, results) => { /* ... */ });

All cache options (TTL, engine, etc...) are described on cacheman README.

Test

Just run:

npm test

License

MIT

Keywords

FAQs

Last updated on 03 Jan 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc