axios-elasticache-memcached-adapter

1.2.0 • Public • Published

axios-elasticache-memcached-adapter

Cache adapter for axios using memcached elasticache

This library was built on top of memcached-elasticache to support http requests caching using AWS ElastiCache

David npm node npm js-standard-style

Disclaimer

This library was built only for server side usage.

Install

npm install --save axios-elasticache-memcached-adapter

Setting up the client

The library setup takes four parameters

  • serverLocations: Server Location of memcached cluster. Check Server Locations documentation from the memcached library.
  • ttl: Cache Time-to-Live in seconds. Default value is 100 seconds.
  • salt: Salt Suffix for the memcached key. Default is empty string ''
  • options: Options object with the memcached client params. Check the client options documentation from the memcached library.

Usage

To use this library, you need to setup the memcached options to create the adapter function and then attach it to the axios instance.

const axios = require('axios')
const axiosCacheMemcached = require('axios-elasticache-memcached-adapter')
 
const memcachedAdapter = axiosCacheMemcached.setup('localhost:11211')
 
const http = axios.create({
  adapter: memcahachedAdapter
})
 
http.get(url, options).then(response => {
  // Cached or Uncached axios response
})

or

const axios = require('axios')
const axiosCacheMemcached = require('axios-elasticache-memcached-adapter')
 
const memcachedAdapter = axiosCacheMemcached.setup('mycfgmemcached.endpoint.elasticache.aws.amazon.com', 600, 'mysalt2.com', { maxValue: 1024 * 1024 * 5 })
 
axios.get(url, {
  params: theparams,
  adapter: memcachedAdapter
})

License

This project is released under the MIT license. See the LICENSE for more information.

Package Sidebar

Install

npm i axios-elasticache-memcached-adapter

Weekly Downloads

11

Version

1.2.0

License

MIT

Unpacked Size

6.38 kB

Total Files

5

Last publish

Collaborators

  • lordferquad