Socket
Book a DemoInstallSign in
Socket

@sailplane/expiring-value

Package Overview
Dependencies
Maintainers
0
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sailplane/expiring-value

Container for a value that is instantiated on-demand (lazy-loaded via factory) and cached for a limited time.

5.0.0
latest
Source
npmnpm
Version published
Weekly downloads
45
-48.86%
Maintainers
0
Weekly downloads
 
Created
Source

@sailplane/expiring-value - on-demand value with timeout

What?

The ExpringValue generic class is a container for a value that is instantiated on-demand (lazy-loaded via factory) and cached for a limited time. Once the cache expires, the factory is used again on next demand to get a fresh version.

This is part of the sailplane library of utilities for AWS Serverless in Node.js.

Why?

ExpiringValue is a container for a value that is instantiated on-demand (lazy-loaded via factory) and cached for a limited time. Once the cache expires, the factory is used again on next demand to get a fresh version.

In Lambda functions, it is useful to cache some data in instance memory to avoid recomputing or fetching data on every invocation. In the early days of Lambda, instances only lasted 15 minutes and thus set an upper-limit on how stale the cached data could be. With instances now seen to last for many hours, a mechanism is needed to deal with refreshing stale content - thus ExpiringValue was born.

ExpiringValue is not limited to Lambdas, though. Use it anywhere you want to cache a value for a limited time. It even works in the browser for client code.

How?

See the docs for usage and examples.

Keywords

factory

FAQs

Package last updated on 08 Feb 2025

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.