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%
Build a tag-based content filtering system that efficiently manages and queries tagged items using set operations.
Your task is to implement a content filtering system that allows:
@generates
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
"""
passProvides async Redis client for set operations and atomic commands.
@satisfied-by