Find answers from the community

Updated yesterday

Building A User-Specific Knowledge Base With Redis And S3

Hey all, I am building an app that I want to give the users the ability to upload their own "knowledge bases". This means each user has there own index saved to redis and backed up on s3. The goal is to attempt to load an index from redis and if it doesnt exist build from s3 and deploy to redis. A regular caching strategy. My current method to check that the index is loading from cache is to do this:

Plain Text
redis_client: TtlRedis = TtlRedis(
            host=os.getenv("REDIS_CLUSTER_ADDRESS", "localhost"),
            password=os.getenv("REDIS_CLUSTER_PASSWORD", None),
            port=os.getenv("REDIS_CLUSTER_PORT", 6379),
            ttl=86400,
        )
        # Initialize Redis vector store
        vector_store = RedisVectorStore(
            redis_client=redis_client,
            schema=await create_schema(user_id, application_id)
        )

        index = VectorStoreIndex.from_vector_store(vector_store)

        # Check if the index exists; create if it doesn't
        if not vector_store.index_exists():
            # try loading from s3 since it is not in redis

Which makes sense in my head, but RedisVectorStore constructor creates an index at the end of it. So there is never a time where vector_store.index_exists() doesn't return True. Maybe I am using this wrong?
Add a reply
Sign up and join the conversation on Discord