Leverege Platform

Leverege Platform

  • Overview
  • JSDocs
  • REST API
  • Help

›Server Libraries

Platform Overview

  • Overview
  • Architecture
  • Core Concepts

Guides

  • Platform Setup
  • Building a Project
  • API UI

Services

  • API Server
  • Message Processor
  • Transponder
  • Reason
  • Scheduler
  • Messenger
  • Emailer
  • Rest Server
  • DB Curator

API

  • API
  • Interface
  • Project
  • System
  • Device
  • Blueprint
  • Collection
  • Child
  • History
  • Scenario
  • Script
  • Template
  • Timer
  • User
  • Users

Server Libraries

  • Log
  • Messages
  • Message Queue
  • Cache
  • Lock
  • Limit
  • Cluster Manager
  • Error
  • Exit

Utilities

  • Promise
  • Data Store
  • Factory
  • Path
  • Reasoner
  • Object Util
  • Array Util
  • String Util
  • Base62 Util
  • Value Cache
  • Validator
  • Lol

UI

  • API Redux
  • UI Builder
  • UI Elements
  • UI Redux
  • UI Mapbox Elements
  • UI Active Theme
  • UI Color Elements
  • UI Linear View Elements

Cache

The Cache library creates an cache to quickly set are retrieve values and speed up the operation of services,

Install

npm install --save @leverege/cache

const Cache = require( '@leverege/cache' );

Usage

In general, use the cacheConfig to drive the type of cache.

const cacheConfig = process.env.CACHE_CONFIG || 
  { type : 'redis', 
    connection : {
      host : '127.0.0.1',
      port : 6379
    }
  };

const cache = Cache.create( { cacheConfig, namespace : 'myApp'} )
...
await cache.set( 'myKey', myValue )  // This will set a value to a global myKey
const v = await cache.get( 'myKey' ) // This will access a global myKey
await cache.setNs( 'myKey', myValue )  // This will set a value to a namespaced myKey (myApp:myKey)
const v = await cache.getNs( 'myKey' ) // This will access a namespaced myKey (myApp:myKey)

Other usage

To make a redis cache:

const cache = Cache.create( { 
    type : 'redis',
    namespace : 'myApp', 
    connection : {
      host : '127.0.0.1',
      port : 6379
    }
  } )
← Message QueueLock →
  • Install
  • Usage
  • Other usage
Leverege Platform
Docs
Overview
Connect
FacebookLinkedInTwitter
Facebook Open Source