---
title: "Prove expiry"
description: "Wait for checkpoint TTL to elapse and verify Aerospike reclaims LangGraph session state."
---

# Prove expiry

> For the complete documentation index see: [llms.txt](https://aerospike.com/docs/llms.txt)
> 
> All documentation pages available in markdown.

Phases 1 through 3 on the previous page showed TTL configuration, a first chat turn, and a successful resume while the checkpoint was still alive. This page runs the full demo without `--skip-wait` to prove what happens after the window closes.

## Run the full lifecycle

1.  From the repository root, run the demo without `--skip-wait`:
    
    Terminal window
    
    ```shell
    uv run python cookbooks/expiring-chat-sessions/demo.py
    ```
    
    Phases 1 through 3 match the `--skip-wait` run: configure TTL, start the session, resume once (four messages total). Phase 4 then waits approximately 70 seconds (one-minute TTL plus a small buffer) so Aerospike can reclaim the records. Phase 5 checks that the checkpoint is gone and invokes the same `thread_id` again.
    
2.  Review Phases 4 and 5 in the output:
    
    Watch two lines: `get_tuple()` is the LangGraph API for reading a checkpoint by ID. Returning `None` confirms the record is gone from Aerospike. `messages stored : 2` confirms LangGraph started a fresh session with no prior history.
    
    ```text
    ================================================================
    
    Phase 4 - Wait 70s for the TTL to elapse
    
    ================================================================
    
      expiry window elapsed.
    
    ================================================================
    
    Phase 5 - Prove the state expired
    
    ================================================================
    
      get_tuple()      : None
    
      raw record       : gone
    
      user      > Hello again?
    
      assistant > Hello again! This looks like a brand-new session to me.
    
      messages stored  : 2  (fresh session -- no prior history)
    
    ================================================================
    
    Result
    
    ================================================================
    
      Aerospike expired the abandoned session automatically.
    
      No cron job, no sweeper, no DELETE query.
    ```
    
3.  Confirm expiry reclaimed the prior session:
    
    By the end of Phase 3 the thread held four messages under `session-demo-001`. Phase 4 waited past the one-minute TTL plus a small buffer without any application code touching the records. Aerospike deleted the checkpoint natively.
    
    Phase 5 called `get_tuple()` on that `thread_id` to confirm the checkpoint was gone, then invoked the graph with the same ID. With nothing left in Aerospike, LangGraph started a fresh two-message session with no prior history.
    
    -   `get_tuple()` returns `None` after the wait, confirming Aerospike removed the checkpoint.
    -   `messages stored` drops from `4` back to `2` on the fresh invoke.
    -   The final assistant line is the third scripted reply (“brand-new session”). It only appears when prior checkpoints are gone.
    
    Aerospike handled expiry automatically. No cron job, sweeper process, or explicit `DELETE` query was required. That means fewer scripts to maintain and test across environments.
    

::: note
The demo waits 70 seconds (one-minute TTL plus a small buffer). Message count is the primary invariant if TTL timing differs slightly.
:::

You configured `AerospikeSaver` with a native TTL, resumed a thread from checkpoints, and verified Aerospike reclaims expired sessions without a cleanup job.

## Stop Aerospike

1.  Stop and remove the Aerospike container:
    
    Terminal window
    
    ```shell
    docker rm -f aerospike
    ```
    

Explore the cookbook source at `cookbooks/expiring-chat-sessions/` in the [langgraph-aerospike repository](https://github.com/aerospike/langgraph-aerospike/tree/main/cookbooks/expiring-chat-sessions) for the full step-by-step code walkthrough.

::: undefined
-   I’ve run the full demo including the TTL wait.
-   I’ve confirmed the post-expiry session has only two messages.
-   I’ve stopped the Aerospike Docker container.
:::

Share

Congratulations on completing this tutorial! Share your achievement with the world and let everyone know about your newly acquired skills.

[](https://www.linkedin.com/feed/?shareActive&mini=true&text=Built%20auto-expiring%20LangGraph%20chat%20sessions%20on%20Aerospike%20TTL.%0A%0ACheckpoints%20expire%20at%20the%20storage%20layer.%20No%20cron%20job%2C%20no%20DELETE%20query.%0A%0A%23Aerospike%20%23LangGraph%20%23AIAgents%20%23DevTools%0A%0Ahttps%3A%2F%2Faerospike.com%2Fdocs%2Fdevelop%2Flanggraph-expiring-chat-sessions "Post to LinkedIn")[](https://bsky.app/intent/compose?text=Built%20auto-expiring%20LangGraph%20chat%20sessions%20on%20Aerospike%20TTL.%0A%0ACheckpoints%20expire%20at%20the%20storage%20layer.%20No%20cron%20job%2C%20no%20DELETE%20query.%0A%0A%23Aerospike%20%23LangGraph%20%23AIAgents%20%23DevTools%0A%0Ahttps%3A%2F%2Faerospike.com%2Fdocs%2Fdevelop%2Flanggraph-expiring-chat-sessions "Post to BlueSky")[](https://twitter.com/intent/tweet?text=Built%20auto-expiring%20LangGraph%20chat%20sessions%20on%20Aerospike%20TTL.%0A%0ACheckpoints%20expire%20at%20the%20storage%20layer.%20No%20cron%20job%2C%20no%20DELETE%20query.%0A%0A%23Aerospike%20%23LangGraph%20%23AIAgents%20%23DevTools%0A%0Ahttps%3A%2F%2Faerospike.com%2Fdocs%2Fdevelop%2Flanggraph-expiring-chat-sessions "Post to Twitter")

::: undefined
-   Learn how to fork from a saved checkpoint in the [Tutorial: Agent path correction with LangGraph](https://aerospike.com/docs/develop/langgraph-agent-path-correction).
    
-   See the [langgraph-checkpoint-aerospike package](https://github.com/aerospike/langgraph-aerospike) on GitHub for API reference.
    
-   Read the [LangGraph persistence documentation](https://langchain-ai.github.io/langgraph/concepts/persistence/) for checkpoint concepts.
:::

[Previous  
Configure TTL, start, and resume](https://aerospike.com/docs/develop/langgraph-expiring-chat-sessions/step/2/part/0/configure-ttl-and-start-session)