Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
apollo-server-caching
Advanced tools
The apollo-server-caching package provides a set of utilities for implementing caching in Apollo Server. It includes interfaces and classes for creating and managing caches, which can help improve the performance of your GraphQL server by reducing the need to repeatedly fetch the same data.
InMemoryLRUCache
The InMemoryLRUCache class provides an in-memory cache with a Least Recently Used (LRU) eviction policy. This is useful for caching data that is frequently accessed but can be evicted when the cache reaches its size limit.
const { InMemoryLRUCache } = require('apollo-server-caching');
const cache = new InMemoryLRUCache();
// Set a value in the cache
cache.set('key', 'value');
// Get a value from the cache
cache.get('key').then(value => console.log(value));
// Delete a value from the cache
cache.delete('key');
PrefixingKeyValueCache
The PrefixingKeyValueCache class allows you to add a prefix to all keys in a base cache. This is useful for namespacing cache entries to avoid key collisions.
const { PrefixingKeyValueCache, InMemoryLRUCache } = require('apollo-server-caching');
const baseCache = new InMemoryLRUCache();
const cache = new PrefixingKeyValueCache(baseCache, 'prefix:');
// Set a value in the cache with a prefix
cache.set('key', 'value');
// Get a value from the cache with a prefix
cache.get('key').then(value => console.log(value));
Errors and Cache
The package provides error handling mechanisms for cache operations. This ensures that your application can gracefully handle scenarios where cache operations fail.
const { InMemoryLRUCache } = require('apollo-server-caching');
const cache = new InMemoryLRUCache();
// Set a value in the cache
cache.set('key', 'value').catch(error => console.error('Error setting cache:', error));
// Get a value from the cache
cache.get('key').then(value => console.log(value)).catch(error => console.error('Error getting cache:', error));
node-cache is a simple and fast Node.js internal caching module. It provides a straightforward API for setting, getting, and deleting cache entries. Unlike apollo-server-caching, it does not include built-in support for LRU eviction or key prefixing.
lru-cache is a highly efficient LRU cache implementation for Node.js. It provides more advanced configuration options compared to the InMemoryLRUCache in apollo-server-caching, such as setting a maximum age for cache entries and custom length calculation functions.
redis is a powerful in-memory data structure store that can be used as a cache. It supports a wide range of data types and provides persistence options. While more complex to set up than apollo-server-caching, it offers greater scalability and flexibility.
FAQs
[![npm version](https://badge.fury.io/js/apollo-server-caching.svg)](https://badge.fury.io/js/apollo-server-caching) [![Build Status](https://circleci.com/gh/apollographql/apollo-server/tree/main.svg?style=svg)](https://circleci.com/gh/apollographql/apoll
The npm package apollo-server-caching receives a total of 548,486 weekly downloads. As such, apollo-server-caching popularity was classified as popular.
We found that apollo-server-caching demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.