RAGChain Docs
  • Introduction
  • Quick Start
  • Installation
  • RAGchain Structure
    • File Loader
      • Dataset Loader
        • Ko-Strategy-QA Loader
      • Hwp Loader
      • Rust Hwp Loader
      • Win32 Hwp Loader
      • OCR
        • Nougat Loader
        • Mathpix Markdown Loader
        • Deepdoctection Loader
    • Text Spliter
      • Recursive Text Splitter
      • Markdown Header Splitter
      • HTML Header splitter
      • Code splitter
      • Token splitter
    • Retrieval
      • BM25 Retrieval
      • Hybrid Retrieval
      • Hyde Retrieval
      • VectorDB Retrieval
    • LLM
    • DB
      • MongoDB
      • Pickle DB
    • Reranker
      • BM25 Reranker
      • UPR Reranker
      • TART Reranker
      • MonoT5 Reranker
      • LLM Reranker
    • Benchmark
      • Auto Evaluator
      • Dataset Evaluators
        • Qasper
        • Ko-Strategy-QA
        • Strategy-QA
        • ms-marco
  • Utils
    • Query Decomposition
    • Evidence Extractor
    • Embedding
    • Slim Vector Store
      • Pinecone Slim
      • Chroma Slim
    • File Cache
    • Linker
      • Redis Linker
      • Dynamo Linker
      • Json Linker
    • REDE Search Detector
    • Semantic Clustering
  • Pipeline
    • BasicIngestPipeline
    • BasicRunPipeline
    • RerankRunPipeline
    • ViscondeRunPipeline
  • For Advanced RAG
    • Time-Aware RAG
    • Importance-Aware RAG
Powered by GitBook
On this page
  • Overview
  • Redis DB?
  • Usage
  1. Utils
  2. Linker

Redis Linker

Redis Linker Class Documentation

Overview

The RedisLinker class is a singleton class that manages Redis. It is used to link database and passage IDs that are stored in retrievals. The class is part of the RAGchain project and is located in the RAGchain/utils/linker/redis_linker.py file.

The class inherits from the BaseLinker class and implements the put_json, get_json, and flush_db abstract methods. It also includes additional methods such as connection_check and __del__.

The 'RedisLinker' class uses the redis Python library to interact with a Redis database. It requires several environment variables to be set, including REDIS_HOST, REDIS_PORT, REDIS_DB_NAME, and REDIS_PW.

Redis DB?

Redis database provides high performance and in-memory data storage, making it an excellent choice for this use case. Its key-value data model allows for quick and efficient retrieval of data, optimizing the retrieval process.

Usage

To use the RedisLinker class, you first need to set the required environment variables. These include LINKER_TYPE, REDIS_HOST, REDIS_PORT, REDIS_DB_NAME, and REDIS_PW.

LINKER_TYPE="redisdb"
REDIS_HOST="your redis host url"
REDIS_PORT="your redis port number"
REDIS_DB_NAME="your redis db name"
REDIS_PW="your redis password"

Here is an example of how to use the RedisLinker class:

from RAGchain.utils.linker.redis_linker import RedisLinker

# Create an instance of the RedisLinker class
linker = RedisLinker()

# Check the connection to the Redis database
if linker.connection_check():
    print("Connected to Redis database")

# Put JSON data into the Redis database
linker.put_json("1234", {"name": "John", "age": 30})

# Get JSON data from the Redis database
data = linker.get_json(["1234"])
print(data)

# Flush the Redis database
linker.flush_db()

Please note that the put_json method requires a unique ID and a JSON data as parameters. The get_json method requires a list of IDs as a parameter. The flush_db method does not require any parameters.

PreviousLinkerNextDynamo Linker

Last updated 1 year ago