@mapbox/tilelive-redis

1.4.0 • Public • Published

Build Status codecov

tilelive-redis

Module for adding a redis-based caching layer in front a node-tilejson tilelive source.

It wraps node-tilejson, providing a new source constructor with redis superpowers:

var options = {
    client: client,             // optional, instantiated redis client
    ttl: <number> or <object>,  // optional, object cache ttl in seconds
    stale: <number> or <object>,// optional, max number of seconds to allow a stale object to be served
    timeout: <number>           // optional, max ms to wait before bypassing redis. Defaults to 50
};
var TileJSON = require('tilelive-redis')(options, require('tilejson'));

new TileJSON( ... )

For options.ttl and options.stale an object may be provided to specify different times for different keys. For example:

var options = {
    ttl: {
        'bananas': 5,
        'oranges': 1000
    }
};

will set any keys matching the string bananas to have a ttl of 5 seconds and any keys matching oranges will be set to have a ttl of 1000 seconds.

Requirements

Required minimal/supported version of redis-server is 2.8.x

Command queue high water mark

node-redis supports a command_queue_high_water option, which tilelive-redis uses in order to avoid back pressure in the application as a result of a failing redis server. tilelive-redis will skip redis and instead request only from the source once the command queue high water mark is hit. The default value for command_queue_high_water is set by node-redis and is 1000; set a custom value in your redis client if you desire.

Readme

Keywords

none

Package Sidebar

Install

npm i @mapbox/tilelive-redis

Weekly Downloads

0

Version

1.4.0

License

none

Unpacked Size

11.7 kB

Total Files

4

Last publish

Collaborators

  • mbx-npm-ci-production
  • mbx-npm-ci-staging
  • mbx-npm-advanced-actions-production
  • mbx-npm-advanced-actions-staging
  • mbx-npm-09-production
  • mbx-npm-08-production
  • mbx-npm-07-production
  • mbx-npm-06-production
  • mbx-npm-05-production
  • mbx-npm-04-production
  • mbx-npm-03-production
  • mbx-npm-02-production
  • mbx-npm-01-production
  • mbx-npm-02-staging
  • mapbox-npm-01
  • mapbox-npm-02
  • mapbox-npm-07
  • mapbox-npm-03
  • mapbox-npm-04
  • mapbox-npm-09
  • mapbox-npm-05
  • mapbox-npm-06
  • mapbox-npm-08
  • mapbox-npm-advanced-actions
  • mapbox-npm-ci
  • mapbox-npm
  • mapbox-admin
  • mapbox-machine-user