Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
@aws-sdk/endpoint-cache
Advanced tools
[![NPM version](https://img.shields.io/npm/v/@aws-sdk/endpoint-cache/latest.svg)](https://www.npmjs.com/package/@aws-sdk/endpoint-cache) [![NPM downloads](https://img.shields.io/npm/dm/@aws-sdk/endpoint-cache.svg)](https://www.npmjs.com/package/@aws-sdk/e
@aws-sdk/endpoint-cache is a package that provides a caching mechanism for AWS SDK endpoints. It helps in reducing the number of endpoint resolution requests by caching the resolved endpoints, thus improving the performance of AWS SDK operations.
Creating an Endpoint Cache
This feature allows you to create an instance of the EndpointCache, which can be used to store and retrieve cached endpoints.
const { EndpointCache } = require('@aws-sdk/endpoint-cache');
const cache = new EndpointCache();
Adding an Endpoint to the Cache
This feature allows you to add an endpoint to the cache with a specified key and expiration time.
const endpoint = { address: 'https://example.com', expiration: Date.now() + 60000 };
cache.set('exampleKey', endpoint);
Retrieving an Endpoint from the Cache
This feature allows you to retrieve an endpoint from the cache using a specified key. If the endpoint is found and has not expired, it will be returned.
const cachedEndpoint = cache.get('exampleKey');
if (cachedEndpoint) {
console.log('Cached endpoint:', cachedEndpoint.address);
} else {
console.log('Endpoint not found in cache');
}
Deleting an Endpoint from the Cache
This feature allows you to delete an endpoint from the cache using a specified key.
cache.delete('exampleKey');
node-cache is a simple and fast Node.js internal caching module. It provides similar functionality to @aws-sdk/endpoint-cache by allowing you to store and retrieve cached data with expiration times. However, it is a more general-purpose caching solution and not specifically tailored for AWS SDK endpoints.
memory-cache is another general-purpose caching module for Node.js. It provides in-memory caching with support for time-to-live (TTL) and cache invalidation. Like node-cache, it is not specifically designed for AWS SDK endpoints but can be used for similar caching purposes.
cache-manager is a multi-store caching module for Node.js that supports various storage backends, including memory, Redis, and more. It offers more flexibility and scalability compared to @aws-sdk/endpoint-cache, but it is also more complex to set up and use.
An internal package
You probably shouldn't, at least directly.
mnemonist/lru-cache
for storing the cache.set
operation stores milliseconds elapsed since the UNIX epoch in Expires param based on CachePeriodInMinutes provided in Endpoint.get
operation returns all un-expired endpoints with their Expires values.getEndpoint
operation returns a randomly selected un-expired endpoint.3.295.0 (2023-03-20)
FAQs
[![NPM version](https://img.shields.io/npm/v/@aws-sdk/endpoint-cache/latest.svg)](https://www.npmjs.com/package/@aws-sdk/endpoint-cache) [![NPM downloads](https://img.shields.io/npm/dm/@aws-sdk/endpoint-cache.svg)](https://www.npmjs.com/package/@aws-sdk/e
The npm package @aws-sdk/endpoint-cache receives a total of 1,626,838 weekly downloads. As such, @aws-sdk/endpoint-cache popularity was classified as popular.
We found that @aws-sdk/endpoint-cache demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers 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.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.