tessl install tessl/pypi-posthog@6.7.0Integrate PostHog into any python application.
Agent Success
Agent success rate when using this tile
89%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.03x
Baseline
Agent success rate without this tile
86%
Build a custom cache provider for PostHog feature flags that coordinates flag definition fetching across multiple worker processes to minimize API calls.
Your implementation should create a cache provider that:
The cache provider must implement these methods:
@generates
from typing import Optional, Dict, Any
class FlagDefinitionCacheProvider:
"""
Cache provider for PostHog feature flag definitions that coordinates
fetching across multiple workers to minimize API calls.
"""
def __init__(self, cache_ttl_seconds: int = 60):
"""
Initialize the cache provider.
Parameters:
- cache_ttl_seconds: int - Time-to-live for cached flag definitions in seconds (default: 60)
"""
pass
def should_fetch_flag_definitions(self) -> bool:
"""
Determine if this worker should fetch new flag definitions.
Implements leader election logic to ensure only one worker fetches at a time.
Returns:
bool - True if this worker should fetch, False if it should use cached data
"""
pass
def get_flag_definitions(self) -> Optional[Dict[str, Any]]:
"""
Retrieve cached flag definitions.
Returns:
Optional[Dict[str, Any]] - The cached flag definitions, or None if no valid cache exists
"""
pass
def on_flag_definitions_received(self, data: Dict[str, Any]) -> None:
"""
Store newly fetched flag definitions in the cache for other workers to use.
Parameters:
- data: Dict[str, Any] - The flag definitions data to cache
"""
pass
def shutdown(self) -> None:
"""
Clean up resources and release any locks held by this cache provider.
"""
passProvides feature flag evaluation and management capabilities.
@satisfied-by