CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-superset-ui--generator-superset

Yeoman generator that scaffolds Superset visualization plugins and packages with proper structure and boilerplate code

63

1.21x
Overview
Eval results
Files

task.mdevals/scenario-9/

Cache Configuration Utility

Build a utility that configures and manages multiple cache layers for a data visualization application.

Requirements

Your utility should provide functionality to:

  1. Configure multiple independent cache instances with different purposes (metadata cache, query results cache, temporary state cache)
  2. Generate cache keys that incorporate user context and security parameters
  3. Implement a cache timeout resolution system that follows a hierarchy: custom value → chart-level → dataset-level → database-level → system default
  4. Provide cache invalidation by resource identifier

Implementation

@generates

API

def configure_caches(config: dict) -> dict:
    """
    Configure multiple cache instances based on provided configuration.

    Args:
        config: Dictionary with cache configurations. Each key is a cache name,
                and each value is a dict with 'backend' and 'timeout' keys.
                Example: {'metadata_cache': {'backend': 'redis', 'timeout': 3600}}

    Returns:
        Dictionary mapping cache names to configured cache instances
    """
    pass

def generate_cache_key(base_key: str, user_id: int, security_filters: list) -> str:
    """
    Generate a cache key that incorporates base key, user context, and security filters.

    Args:
        base_key: Base identifier for the cached resource
        user_id: User identifier for per-user caching
        security_filters: List of security filter strings to include in key

    Returns:
        A deterministic cache key string that uniquely identifies the cached item
    """
    pass

def resolve_cache_timeout(custom: int = None, chart: int = None,
                         dataset: int = None, database: int = None,
                         default: int = 300) -> int:
    """
    Resolve cache timeout using hierarchy: custom → chart → dataset → database → default.

    Args:
        custom: Custom timeout value (highest priority)
        chart: Chart-level timeout
        dataset: Dataset-level timeout
        database: Database-level timeout
        default: System default timeout (lowest priority)

    Returns:
        The resolved timeout value in seconds
    """
    pass

def invalidate_cache_by_resource(cache_instance: dict, resource_uid: str) -> list:
    """
    Invalidate all cache entries associated with a specific resource.

    Args:
        cache_instance: The cache instance dictionary (from configure_caches)
        resource_uid: Unique identifier for the resource

    Returns:
        List of invalidated cache keys
    """
    pass

Test Cases

  • Configuring three cache instances with different backends returns a dictionary with all three cache configurations @test
  • Generating cache keys with the same inputs produces identical keys, but different user_ids produce different keys @test
  • Resolving timeout with only default value returns the default @test
  • Resolving timeout with custom value ignores all other values and returns custom @test
  • Resolving timeout without custom but with chart value returns chart value @test
  • Invalidating cache by resource identifier removes all keys containing that resource_uid @test

Dependencies { .dependencies }

apache-superset { .dependency }

Provides caching infrastructure and utilities for business intelligence applications.

Install with Tessl CLI

npx tessl i tessl/npm-superset-ui--generator-superset

tile.json