tessl install tessl/pypi-aioredis@2.0.0asyncio (PEP 3156) Redis support
Agent Success
Agent success rate when using this tile
98%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.01x
Baseline
Agent success rate without this tile
97%
A session token management system that stores and manages user session tokens with automatic expiration using a Redis backend.
Store session tokens for users with automatic expiration.
Retrieve active session tokens for users.
Check if a user has an active session.
Remove session tokens when users log out.
@generates
"""Session token manager for handling user authentication tokens in Redis."""
from typing import Optional, Dict, List
class SessionManager:
"""Manages user session tokens with automatic expiration."""
def __init__(self, redis_client):
"""
Initialize the session manager.
Args:
redis_client: An aioredis client instance
"""
pass
async def store_token(self, user_id: str, token: str, expiry_seconds: int) -> None:
"""
Store a session token for a user with automatic expiration.
Args:
user_id: The user identifier
token: The session token to store
expiry_seconds: Number of seconds until the token expires
"""
pass
async def store_tokens(self, tokens: Dict[str, str], expiry_seconds: int) -> None:
"""
Store multiple session tokens at once with automatic expiration.
Args:
tokens: Dictionary mapping user_id to token
expiry_seconds: Number of seconds until tokens expire
"""
pass
async def get_token(self, user_id: str) -> Optional[str]:
"""
Retrieve the session token for a user.
Args:
user_id: The user identifier
Returns:
The token string if it exists, None otherwise
"""
pass
async def get_tokens(self, user_ids: List[str]) -> Dict[str, Optional[str]]:
"""
Retrieve session tokens for multiple users at once.
Args:
user_ids: List of user identifiers
Returns:
Dictionary mapping user_id to token (or None if not found)
"""
pass
async def token_exists(self, user_id: str) -> bool:
"""
Check if a user has an active session token.
Args:
user_id: The user identifier
Returns:
True if an active token exists, False otherwise
"""
pass
async def delete_token(self, user_id: str) -> None:
"""
Remove a session token for a user.
Args:
user_id: The user identifier
"""
pass
async def delete_tokens(self, user_ids: List[str]) -> None:
"""
Remove session tokens for multiple users at once.
Args:
user_ids: List of user identifiers
"""
passProvides async Redis client functionality for storing and retrieving session data.
@satisfied-by