🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@viestimedia/cachified-ioredis-adapter

Package Overview
Dependencies
Maintainers
4
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@viestimedia/cachified-ioredis-adapter

ioredis adapter for cachified

latest
npmnpm
Version
1.0.4
Version published
Maintainers
4
Created
Source

ioredis adapter for Cachified

Setup

Install with npm i @viestimedia/cachified-ioredis-adapter.

import { cachified as c, CachifiedOptions } from '@epic-web/cachified';
import { ioredisAdapter } from '@viestimedia/cachified-ioredis-adapter';

export function cachified<Value>(options: Omit<CachifiedOptions<Value>, 'cache'>) {
  return c({
    cache: ioredisAdapter(redis, {
      logErrors: process.env.NODE_ENV === 'production',
      throwErrors: process.env.NODE_ENV !== 'production',
    }),
    ...options,
  });
}

Usage

const data = await cachified({
  key: 'something',
  ttl: 1000 * 60 * 60 * 24,

  async getFreshValue() {
    console.info(`Fetching fresh data`)
    const res = await fetch(process.env.API_URL)
    return res.json()
  },
})

Licence

MIT

FAQs

Package last updated on 22 Nov 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