Skip to content

Cache does not expire despite cache_ttl passed. #18

@isthisnagee

Description

@isthisnagee

Hello!

When I set a low cache_ttl, get a FF value, sleep for a while, then get the value again, I don't get the latest value, I just get what was cached. This behaviour seems wrong, and isn't consistent with the Growthbook client

To put the above words into code:

# When running this, don't forget to define GB_API_HOST and GB_CLIENT_KEY
import time
from openfeature import api as openfeature_api
from growthbook_openfeature_provider import (
    GrowthBookProvider,
    GrowthBookProviderOptions,
)


gb_openfeature_provider = GrowthBookProvider(
    GrowthBookProviderOptions(
        api_host=GB_API_HOST,
        client_key=GB_CLIENT_KEY,
        cache_ttl=1,
        qa_mode=True,
        enabled=True,
    )
)
gb_openfeature_provider.initialize_sync()
openfeature_api.set_provider(gb_openfeature_provider)
gb_of_client = openfeature_api.get_client()

# make sure my-flag exists in growthbook
first_result = gb_of_client.get_boolean_value("my_flag", False)
time.sleep(15)  # update the value in the UI.
second_result = gb_of_client.get_boolean_value("my_flag", False)

assert first_result != second_result, "We slept much longer than the cache ttl, should get latest value"

Should the above example work, or have I misunderstood the API?

I have a test repo here that compares the GrowthBook client with OpenFeature using the GrowthBook provider: https://github.com/isthisnagee/growthbook-openfeature-provider-python-issue

In the example above, the GrowthBook client gets the latest value after the sleep call, but the openfeature provider doesn't.

Thanks!!

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