Skip to content

How to add TTL for RedisStore #27

Closed
@YolandaAlvarez

Description

@YolandaAlvarez

Hello, I have a project and I am using the same configuration for Cross-thread memory shown in https://redis.io/blog/langgraph-redis-build-smarter-ai-agents-with-memory-persistence/ .
The part where they initialize the checkpointer and store is this:

#Initialize Redis persistence and store
REDIS_URI = "redis://localhost:6379"
with RedisSaver.from_conn_string(REDIS_URI) as checkpointer:
    checkpointer.setup()
     
    with RedisStore.from_conn_string(REDIS_URI) as store:
        store.setup()
         
        # Compile graph with both checkpointer and store
        graph = builder.compile(checkpointer=checkpointer, store=store)

I want to know how to implement TTL in RedisStore.

In langgraph-redis/langgraph/store/redis/init.py in the definition of from_conn_string I can see the parameter ttl: Optional[dict[str, Any]] = None) .
I suppose I need to use that, do you have an example?
How can I set the TTL to 24hrs for the graph checkpoints I'm storing in RedisStore?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions