growthbook / growthbook/growthbook-python

Documentation references non-existent `AbstractAsyncFeatureCache` class

Open
#79 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
43
Forks
26
Avg merge
2h 45m
Merged PRs (30d)
7

Description

## 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:

```python
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:

```python
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:

```bash
$ 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:

```python
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!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.