1.0.7 • Published 11 months ago

relached v1.0.7

Weekly downloads
-
License
MIT
Repository
-
Last release
11 months ago

Here's the README.md file for the relached Redis client in Markdown format:

Relached Redis Client

Installation

To use the relached library for Redis in your Node.js application, follow these steps:

Install Dependencies

First, ensure you have Node.js and npm (or yarn) installed. Then, install relached:

Using npm:

npm install relached
Or using yarn:

yarn add relached


Set Up Environment Variables
Create a .env file in your project root with the Redis server URL:


REDIS_URL=redis://127.0.0.1:6379
Replace redis://127.0.0.1:6379 with your Redis server URL if different.

Usage
Initialize Redis Client
Import and initialize the Redis client in your application:


import { initRedisClient } from 'relached';

// Initialize the Redis client
initRedisClient();
Set a Value
To set a value in Redis:


import { set } from 'relached';

const key = 'myKey';
const value = 'myValue';
const expiresIn = 3600; // Optional, expiration time in seconds

set(key, value, expiresIn)
  .then(() => console.log('Value set successfully'))
  .catch(err => console.error('Error setting value:', err));
Get a Value
To retrieve a value from Redis:


import { get } from 'relached';

const key = 'myKey';

get(key)
  .then(value => {
    if (value) {
      console.log('Value retrieved:', value);
    } else {
      console.log('No value found for the key');
    }
  })
  .catch(err => console.error('Error getting value:', err));
Delete a Value
To delete a value from Redis:


import { del } from 'relached';

const key = 'myKey';

del(key)
  .then(() => console.log('Value deleted successfully'))
  .catch(err => console.error('Error deleting value:', err));


You can save this content in a `README.md` file in your project directory.
1.0.7

11 months ago

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago