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-4/

Tag-based Content Filter

Build a tag-based content filtering system that efficiently manages and queries tagged items using set operations.

Requirements

Your task is to implement a content filtering system that allows:

  1. Tag Management: Track which items belong to each tag category
  2. Filter Operations: Find items that match various tag combinations:
    • Items with ALL specified tags (intersection)
    • Items with ANY specified tags (union)
    • Items with certain tags but NOT others (difference)
  3. Item Movement: Move items between tag categories atomically
  4. Result Caching: Store computed filter results for repeated queries

Capabilities

Store intersection results

  • Given sets "tag:python" with items ["item1", "item2", "item3"] and "tag:async" with items ["item2", "item3", "item4"], computing and storing the intersection in "cache:python_and_async" results in ["item2", "item3"] @test

Store union results

  • Given sets "tag:database" with items ["item1", "item2"] and "tag:cache" with items ["item3", "item4"], computing and storing the union in "result:db_or_cache" results in ["item1", "item2", "item3", "item4"] @test

Store difference results

  • Given set "tag:all_users" with items ["user1", "user2", "user3"] and "tag:premium" with items ["user2"], computing and storing the difference in "tag:free_users" results in ["user1", "user3"] @test

Move items between tag sets

  • Given "tag:pending" with item "task5" and "tag:completed" without it, after moving "task5" from "tag:pending" to "tag:completed", "tag:pending" no longer contains "task5" and "tag:completed" now contains it @test

Implementation

@generates

API

class TagFilter:
    """
    A tag-based content filtering system using Redis sets.

    This class provides methods to manage tagged items and perform
    set operations to filter content based on tag combinations.
    """

    def __init__(self, redis_client):
        """
        Initialize the TagFilter with a Redis client.

        Args:
            redis_client: An aioredis client instance for Redis operations
        """
        pass

    async def compute_intersection(self, tag_keys: list, result_key: str) -> int:
        """
        Compute intersection of multiple tag sets and store the result.

        Finds items that have ALL of the specified tags.

        Args:
            tag_keys: List of Redis keys for tag sets to intersect
            result_key: Redis key where the intersection result will be stored

        Returns:
            Number of items in the resulting intersection set
        """
        pass

    async def compute_union(self, tag_keys: list, result_key: str) -> int:
        """
        Compute union of multiple tag sets and store the result.

        Finds items that have ANY of the specified tags.

        Args:
            tag_keys: List of Redis keys for tag sets to union
            result_key: Redis key where the union result will be stored

        Returns:
            Number of items in the resulting union set
        """
        pass

    async def compute_difference(self, main_key: str, exclude_keys: list, result_key: str) -> int:
        """
        Compute difference between a main set and other sets, storing the result.

        Finds items in main set that are NOT in any of the exclude sets.

        Args:
            main_key: Redis key for the main set
            exclude_keys: List of Redis keys for sets to exclude
            result_key: Redis key where the difference result will be stored

        Returns:
            Number of items in the resulting difference set
        """
        pass

    async def move_item(self, item: str, from_key: str, to_key: str) -> bool:
        """
        Atomically move an item from one tag set to another.

        Args:
            item: The item identifier to move
            from_key: Redis key for the source tag set
            to_key: Redis key for the destination tag set

        Returns:
            True if the item was successfully moved, False if item was not in source set
        """
        pass

Dependencies { .dependencies }

aioredis { .dependency }

Provides async Redis client for set operations and atomic commands.

@satisfied-by