0.0.2 • Published 1 year ago

workers-redis v0.0.2

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

workers-redis

A very simple Redis client library for Cloudflare Workers

Features

  • Password authentication
  • Lightweight and efficient
  • Easy to install and use

Installation

npm install workers-redis

Ensure that you have Node.js and npm installed on your system.

Usage

Here's an example of how to use the Redis client library in your Cloudflare Workers script:

import { RedisClient } from "workers-redis";

export default {
  async fetch(request: Request, env: Env, ctx: ExecutionContext) {
    const redis = new RedisClient("hostname", 6379, "password");

    try {
      await redis.connect();

      const key = "mykey";
      const value = await redis.get(key);

      return new Response(value);
    } catch (error) {
      console.error("Error:", error);
      return new Response("Internal Server Error", { status: 500 });
    } finally {
      await redis.disconnect();
    }
  },
};
0.0.2

1 year ago

0.0.1

1 year ago