tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Generative AI > Google Gemini API > ADK with Redis for Fast Agent State Storage

ADK with Redis for Fast Agent State Storage

Author: Venkata Sudhakar

ADK agents maintain state across turns using session services. The default InMemorySessionService is lost when the process restarts. For production, you need a persistent store. Redis is ideal - it offers microsecond reads, TTL-based expiry, and horizontal scaling. ShopMax India uses Redis to maintain shopping cart and customer preference state across agent sessions.

You implement a custom session service by extending the ADK BaseSessionService class. The service stores session data as JSON in Redis with a configurable TTL, and loads it back on each request.

The below example shows how ShopMax India implements a Redis-backed session service for the product recommendation agent.


Using the Redis session service with an ADK agent,


It gives the following output,

Session created: sess_7f3a91 (stored in Redis)

For video editing under Rs 60,000, I recommend:
1. ASUS VivoBook 15 OLED - Rs 54,990 (Ryzen 7, 16GB RAM)
2. Lenovo IdeaPad Slim 5 - Rs 57,500 (Intel i7, 512GB SSD)
3. HP Pavilion 15 - Rs 59,999 (Ryzen 5, dedicated GPU)

Best pick: ASUS VivoBook for colour accuracy on the OLED display.

In production at ShopMax India, use Google Cloud Memorystore for Redis with VPC peering to your Cloud Run services. Set TTL to match your session timeout policy and monitor cache hit rates in Cloud Monitoring to ensure Redis is serving most session lookups.


 
  


  
bl  br