New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

lay-away

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lay-away

A simple cache that's good enough

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Lay Away

A simple cache that's good enough.

Getting Started Examples

Getting Started

  1. Add dependency to project

    npm install --save lay-away

  2. Create instance of lay-away

    import Cache from 'lay-away'

     const cache = Cache()
    
  3. Write data to the cache

    cache.set('a', 1)

  4. Read data from the cache

    cache.get('a')

Examples

Set entry

import Cache from 'lay-away'

const cache = Cache()
cache.set('a', 1)

console.log(cache.get('a'))
// => 1

Set entry with TTL

import Cache from 'lay-away'
import { setTimeout as sleep } from 'node:timers/promises'

const cache = Cache()
cache.set('a', 1, 1000)

console.log(cache.get('a'))
// => 1

await sleep(1000)

console.log(cache.get('a'))
// => undefined

Delete entry

import Cache from 'lay-away'

const cache = Cache()
cache.set('a', 1)

console.log(cache.get('a'))
// => 1

cache.del('a')

console.log(cache.get('a'))
// => undefined

Clear all entries

import Cache from 'lay-away'

const cache = Cache()
cache.set('a', 1)

console.log(cache._data.size)
// => 1

cache.clear()

console.log(cache._data.size)
// => 0

FAQs

Package last updated on 30 May 2024

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc