or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/aioredis@2.0.x
tile.json

tessl/pypi-aioredis

tessl install tessl/pypi-aioredis@2.0.0

asyncio (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%

task.mdevals/scenario-3/

Session Token Manager

A session token management system that stores and manages user session tokens with automatic expiration using a Redis backend.

Capabilities

Token Storage

Store session tokens for users with automatic expiration.

  • When storing a token "abc123" for user "user1" with 3600 second expiry, the token can be retrieved within the expiry period @test
  • When storing multiple tokens for different users in a single operation, all tokens are stored correctly @test

Token Retrieval

Retrieve active session tokens for users.

  • When retrieving an existing token for a user, the correct token value is returned @test
  • When retrieving multiple tokens for different users in a single operation, all correct token values are returned @test
  • When retrieving a token that doesn't exist, None is returned @test

Token Validation

Check if a user has an active session.

  • When checking if a user with an active token exists, returns True @test
  • When checking if a user without a token exists, returns False @test

Token Cleanup

Remove session tokens when users log out.

  • When deleting a single token, the token is removed and no longer retrievable @test
  • When deleting multiple tokens in a single operation, all specified tokens are removed @test

Implementation

@generates

API

"""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
        """
        pass

Dependencies { .dependencies }

aioredis { .dependency }

Provides async Redis client functionality for storing and retrieving session data.

@satisfied-by