ParserCache

This extension adds LRU caching to the parsing step of query execution to improve performance by caching the parsed result in memory.

Usage example:

import strawberry
from strawberry.extensions import ParserCache
schema = strawberry.Schema(
Query,
extensions=[
ParserCache(),
]
)

API reference:

class ParserCache(maxsize=None)

maxsize: Optional[int] = None

Set the maxsize of the cache. If maxsize is set to None then the cache will grow without bound.

More info: https://docs.python.org/3/library/functools.html#functools.lru_cache

More examples:

Using maxsize
import strawberry
from strawberry.extensions import ParserCache
schema = strawberry.Schema(
Query,
extensions=[
ParserCache(maxsize=100),
]
)

Was this helpful?

Edit on Github

Newsletter 💌

Do you want to receive the latest updates on Strawberry? Subscribe to our newsletter!