This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

apollo-server-compression-cache-wrapper
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

CompressionCacheWrapper

Tests CodeQL npm version npm downloads

This package exports an implementation of KeyValueCache that allows wrapping any other Apollo KeyValueCache implementation with a configurable (default: zlib deflate) compression layer. Its main goal is to limit the amount of memory used by the caching environment and at the same time the amount of data being in-transit from and to the caching environment.

Usage

const { RedisCache } = require('apollo-server-cache-redis');
const { CompressionCacheWrapper } = require('apollo-server-compression-cache-wrapper');
const 'zlib' = require('zlib');

const redisCache = new RedisCache({
  host: 'redis-server',
});

const server = new ApolloServer({
  typeDefs,
  resolvers,
  cache: new CompressionCacheWrapper(redisCache, {
    compress: (data: Buffer) => zlib.deflateSync(data, { level: 1 }),
    decompress: (data: Buffer) => zlib.inflateSync(data),
    minimumCompressionSize: 262144,
  }),
  dataSources: () => ({
    moviesAPI: new MoviesAPI(),
  }),
});

Options

  • compress (default: zlib deflate) - defines a custom compression method taking and returning a Buffer.
  • decompress (default: zlib deflate) - defines a custom decompression method taking and returning a Buffer.
  • minimumCompressionSize (default: 262144) - defines minimal length of the data string, after exceeding which data proxied to wrapped cache are compressed before being passed forward.

Debug

For better performance monitor of CompressionCacheWrapper module in your app, run your app with DEBUG env.

To get all debug messages from all modules:

DEBUG=* npm run start

To get debug messages only from compression-wrapper module:

DEBUG=compression-wrapper npm run start

Package Sidebar

Install

npm i apollo-server-compression-cache-wrapper

Weekly Downloads

1

Version

1.1.0

License

MIT

Unpacked Size

14.1 kB

Total Files

7

Last publish

Collaborators

  • kdybicz