GraphRAG Cache
This package contains a collection of utilities to handle GraphRAG caching implementation.
Basic
This example shows how to create a JSON cache with file storage using the GraphRAG cache package's configuration system.
Open the notebook to explore the basic example code
Custom Cache
This example demonstrates how to create a custom cache implementation by extending the base Cache class and registering it with the GraphRAG cache system. Once registered, the custom cache can be instantiated through the factory pattern using either CacheConfig or directly via cache_factory, allowing for extensible caching solutions tailored to specific needs.
Open the notebook to explore the basic custom example code
Details
By default, the create_cache comes with the following cache providers registered that correspond to the entries in the CacheType enum.
JsonCacheMemoryCacheNoopCacheSQLiteCache
SQLiteCache stores JSON-serializable values in a local SQLite database. It uses
WAL mode and short-lived connections so multiple workers can safely share the
same database. Configure it with:
cache:
type: sqlite
storage:
type: file
base_dir: cache
database_name: cache.db
The database is created within the configured file storage. SQLite requires local random-access file operations, so blob and Cosmos storage are not supported. Child caches use isolated namespaces within the same database.
The preregistration happens dynamically, e.g., JsonCache is only imported and registered if you request a JsonCache with create_cache(CacheType.Json, ...). There is no need to manually import and register builtin cache providers when using create_cache.
If you want a clean factory with no preregistered cache providers then directly import cache_factory and bypass using create_cache. The downside is that cache_factory.create uses a dict for init args instead of the strongly typed CacheConfig used with create_cache.
from graphrag_cache.cache_factory import cache_factory
from graphrag_cache.json_cache import JsonCache
# cache_factory has no preregistered providers so you must register any
# providers you plan on using.
# May also register a custom implementation, see above for example.
cache_factory.register("my_cache_impl", JsonCache)
cache = cache_factory.create(
strategy="my_cache_impl", init_args={"some_setting": "..."}
)
...
Metadata
Release files for graphrag-cache 3.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| graphrag_cache-3.2.0.tar.gz | 9.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| graphrag_cache-3.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.1 kB
Release files / graphrag_cache-3.2.0.tar.gz
| Download URL | graphrag_cache-3.2.0.tar.gz |
|---|---|
| Size | 9.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c88f73cb7b619df5383b2e1c2eb479b3a53fdcaee8d4a29b2413f8999b2f492d
|
|
BLAKE2b-256 checksum How to use checksums |
532d2bde64a78007925fe5b9d03ce23c6ab9323854e0841c8f097c74b3c15d9e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.17
|
Release files / graphrag_cache-3.2.0-py3-none-any.whl
| Download URL | graphrag_cache-3.2.0-py3-none-any.whl |
|---|---|
| Size | 12.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
186499291da23212c6f208fa203bfa47702bbd4e00ff86198b5aa0f2f2fa1b5c
|
|
BLAKE2b-256 checksum How to use checksums |
335ec8e514aca296bae7745b1a357d3bd3876c7b47f6914f8714c8d91b438c01
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.17
|