Skip to content

Documentation references non-existent AbstractAsyncFeatureCache class #79

@darwing1210

Description

@darwing1210

Description

The Python SDK documentation at https://docs.growthbook.io/lib/python shows examples using AbstractAsyncFeatureCache for custom async caching, but this class doesn't exist in the latest released version (1.4.7).

Documentation Example

The docs show this example for custom async caching:

from redis.asyncio import Redis
from growthbook import GrowthBookClient, Options, AbstractAsyncFeatureCache

class AsyncRedisFeatureCache(AbstractAsyncFeatureCache):
    def __init__(self):
        self.redis = Redis(host='localhost', port=6379, decode_responses=True)
        self.prefix = "gb:async:"

    async def get(self, key: str):
        data = await self.redis.get(self.prefix + key)
        return None if data is None else json.loads(data)

    async def set(self, key: str, value: dict, ttl: int) -> None:
        await self.redis.set(
            self.prefix + key,
            json.dumps(value),
            ex=ttl
        )

    async def close(self):
        await self.redis.close()

# Create client with custom cache
client = GrowthBookClient(
    Options(
        api_host="https://cdn.growthbook.io",
        client_key="sdk-abc123",
        cache=cache  # <-- Options doesn't support 'cache' parameter
    )
)

Actual Behavior

When attempting to use this code with growthbook==1.4.7:

from growthbook import AbstractAsyncFeatureCache
# ImportError: cannot import name 'AbstractAsyncFeatureCache' from 'growthbook'

Additionally, the Options class doesn't have a cache parameter.

Investigation

Checking the installed package:

$ pip show growthbook
Name: growthbook
Version: 1.4.7

$ python -c "import growthbook; print([x for x in dir(growthbook) if 'Async' in x or 'Cache' in x])"
['AbstractFeatureCache', 'CacheEntry', 'FeatureCache', 'InMemoryFeatureCache']
# No AbstractAsyncFeatureCache

The package only contains:

  • AbstractFeatureCache (sync, for legacy GrowthBook class)
  • FeatureCache (internal class used by GrowthBookClient)
  • InMemoryFeatureCache (sync implementation)

Expected Behavior

Either:

  1. Documentation should be updated to remove references to AbstractAsyncFeatureCache and custom async caching for version 1.4.7
  2. Or the documentation should indicate this is a feature coming in a future version (e.g., "Available in v2.0+")
  3. Or AbstractAsyncFeatureCache should be added to the library to match the documentation

Workaround

For now, custom caching is only supported for the synchronous client:

from growthbook import AbstractFeatureCache, feature_repo

class RedisFeatureCache(AbstractFeatureCache):
    # Sync implementation...
    pass

# Configure globally for sync client
feature_repo.set_cache(RedisFeatureCache())

Environment

  • Python: 3.12
  • growthbook: 1.4.7
  • OS: macOS/Linux

Additional Context

This issue was discovered while implementing Redis caching for a Django application following the official documentation. The documentation appears to be written for a future or unreleased version of the SDK.

Would appreciate clarification on:

  1. When will AbstractAsyncFeatureCache be available?
  2. Should we expect this in a minor or major version update?
  3. Can the documentation be tagged with version availability?

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions