Skip to content

This package provides a way to use Upstash Redis as a KV adapter with Payload.

License

Notifications You must be signed in to change notification settings

rubix-studios-pty-ltd/payload-upstash

Repository files navigation

PayloadCMS + Upstash KV Adapter

This package provides a way to use Upstash as a KV adapter with Payload.

Installation

pnpm add @rubixstudios/payload-upstash

Usage

import { upstashKVAdapter } from '@rubixstudios/payload-upstash'

export default buildConfig({
  collections: [Media],
  kv: upstashKVAdapter({
    // Upstash connection URL. Defaults to process.env.UPSTASH_URL
    url: process.env.UPSTASH_URL!,
    token: process.env.UPSTASH_TOKEN!,
    // Optional prefix for Upstash Redis keys to isolate the store. Defaults to 'payload-kv:'
    keyPrefix: 'kv-storage:',
    // Optional TTL configuration for automatic expiration by key prefix
    ttl: [
      { prefix: 'session:', ttl: 3600 },
      { prefix: 'cache:', ttl: 300 },
      { prefix: 'temp:', ttl: 60 },
    ],
  }),
})

Then you can access the KV storage using payload.kv:

await payload.kv.set('key', { value: 1 })
const data = await payload.kv.get('key')
payload.logger.info(data)

About

This package provides a way to use Upstash Redis as a KV adapter with Payload.

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

No packages published

Contributors 2

  •  
  •