Socket
Socket
Sign inDemoInstall

jsredisorm

Package Overview
Dependencies
10
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    jsredisorm

jsRedisORM is a Node.js library that provides an Object-Relational Mapping (ORM) interface for interacting with Redis. It simplifies the process of working with Redis as a cache or a data store in your Node.js applications.


Version published
Weekly downloads
1
Maintainers
1
Install size
962 kB
Created
Weekly downloads
 

Readme

Source

jsRedisORM

jsRedisORM is a Node.js library that provides an Object-Relational Mapping (ORM) interface for interacting with Redis 4.6.7. It simplifies the process of working with Redis as a cache or a data store in your Node.js applications.

Installation

You can install jsRedisORM using npm:

npm install jsredisorm

Usage

To use jsRedisORM in your project, import the createClient function from the Redis library and the jsRedisORM class from the jredis-orm package:

import { createClient } from "redis";
import jsRedisORM from "jsRedisORM.js";

Create an instance of the jsRedisORM class by providing the required Redis connection details:

const redis = new jsRedisORM(
  host,
  port,
  (username = null),
  (password = null),
  (tlsOptions = null),
  (dbIndex = 0),
  (keyPrefix = "")
);

Connecting to Redis

Before interacting with Redis, you need to establish a connection. Use the connect method to connect to the Redis server:

await redis.connect();

###Caching Data NodeRedisORM provides methods to set, get, and delete key-value pairs, lists, sets, hashes, and more. Here are some examples:

// Set a value in Redis
await redis.set("key", "value");

// Get a value from Redis
const value = await redis.get("key");

// Delete a key from Redis
await redis.delete("key");

Disconnecting from Redis

To disconnect from the Redis server, you can use the quit method:

await redis.quit();

API Documantation

The following methods are available in the jsRedisORM class:

connect(): Connects to the Redis server.
set(key, value, expiration): Sets a value for the specified key in Redis.
get(key): Retrieves the value for the specified key from Redis.
delete(key): Deletes the specified key from Redis.
setList(key, values, expiration): Sets a list of values for the specified key in Redis.
getList(key): Retrieves the list of values for the specified key from Redis.
deleteList(key): Deletes the list associated with the specified key from Redis.
setSet(key, values, expiration): Sets a set of values for the specified key in Redis.
getSet(key): Retrieves the set of values for the specified key from Redis.
deleteSet(key): Deletes the set associated with the specified key from Redis.
setHash(key, values, expiration): Sets a hash of key-value pairs for the specified key in Redis.
getHash(key): Retrieves the hash of key-value pairs for the specified key from Redis.
deleteHash(key): Deletes the hash associated with the specified key from Redis.

Contributing

Contributions to jsRedisORM are welcome! If you find any bugs or have suggestions for improvements, please feel free to open an issue or submit a pull request.

Keywords

FAQs

Last updated on 27 Jun 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc