Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

loopback-mixin-cache

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

loopback-mixin-cache

Redis cache mixin for LoopBack.

  • 0.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-71.43%
Maintainers
1
Weekly downloads
 
Created
Source

Redis cache mixin for LoopBack

loopback-mixin-cache adds easy to use redis caching to any of your models.

Installation

$ npm i loopback-mixin-cache --save

Config

Server Config

With loopback-boot@v2.8.0 mixinSources have been implemented in a way which allows for loading this mixin without changes to the server.js file previously required. Just add "../node_modules/loopback-mixin-cache" to the mixins property of your server/model-config.json.

{
  "_meta": {
    "mixins": [
      "loopback/common/mixins",
      "../node_modules/loopback-mixin-cache",
      "../common/mixins"
    ]
  }
}

Model Config

To use with your models just add Cache: true to mixins in your model config and the default options will be used:

{
  "name": "Model",
  "properties": {
    "name": {
      "type": "string",
    }
  },
  "mixins": {
    "Cache": true
  }

  ...

  // you can also overide the default values:
  "mixins": {
    "Cache": {
      "ttl": 30    // time to live (how long an item is being cached), default: 120
    }
  }
}

Global Config

It is also possible to configure the mixin globally in your config.json. Just add cache and use the same options as with the model above:

{
  "cache": {
    "ttl": 30    // time to live (how long an item is being cached), default: 120
  }
}

ToDo and ideas

  • optimize cache keys
  • add override parameter (e.g. ?noCache=true)
  • add better usage documentation to this readme (e.g. noCaheFlag)
  • find better solution for searching and deleting cached items
  • add response headers with information about the cache (environment agnostic)

License

MIT

Changelog

v0.3.0

  • Remove babel
  • min. node version is now 8.x.x

v0.2.0

  • Update dev dependencies

v0.1.0

  • Initial stable version

Keywords

FAQs

Package last updated on 28 Nov 2019

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc