Skip to content

Commit

Permalink
Adds documentation for the asset chache
Browse files Browse the repository at this point in the history
  • Loading branch information
PascalSenn committed Feb 19, 2024
1 parent 1f34422 commit a7d2aef
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 2 deletions.
7 changes: 6 additions & 1 deletion website/src/docs/bananacakepop/v2/apis/client-registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,13 @@ public void ConfigureServices(IServiceCollection services)
}
```

# Integrating with Continuous Integration
# Setup the cache
You can setup a second level cache for persisted queries for improving your system's resilience and
performance.

Find out more about the cache here [Caching](/docs/bananacakepop/v2/apis/fusion).

# Integrating with Continuous Integration
Integrating the client registry into your Continuous Integration/Continuous Deployment (CI/CD) pipeline maximizes their benefits. It ensures that the clients in your API are always up-to-date and tested against potential breaking changes.

The schema and client registries work hand-in-hand to ensure the smooth functioning of your API. As you make changes to your schema, the schema registry helps manage these changes, preventing inadvertent breaking changes and preserving a history of your schemas. As you validate, upload, and publish new schemas, the client registry ensures that your clients remain compatible with these changes.
Expand Down
62 changes: 62 additions & 0 deletions website/src/docs/bananacakepop/v2/apis/fusion.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,3 +292,65 @@ Now your gateway will send the telemetry data to Banana Cake Pop. To connect you
}
}
```
# Cache
The `BananaCakePop.Services` package provides caching for persisted queries and fusion
configurations, improving your system's resilience and performance. By first accessing a local cache
for configurations before querying the server, your infrastructure becomes more robust, minimizing
dependency on real-time server communications. This approach not only speeds up access to necessary
configurations but also ensures your system remains stable and responsive, even during network
fluctuations.
We offer two types of caches: `FileSystemCache` for storing data on your local file system, and
`BlobStorageCache` for storing data in Azure Blob Storage.
Here’s how you add caching to your service:
For GraphQL services:
```csharp
services
.AddGraphQLServer()
.AddAssetCache<TCache>()
```
For fusion services:
```csharp
services
.AddFusionGatewayServer()
.ConfigureFromCloud()
.AddAssetCache<TCache>()
```
## `FileSystemCache`
This default cache stores data in the `assets` folder of your project. You can change the folder like this:
```csharp
services
.AddGraphQLServer()
.AddFileSystemAssetCache(x =>
{
x.CacheDirectory = "cache"; // Your cache folder
})
```
## `BlobStorageCache`
This cache stores your data in Azure Blob Storage. Set it up with:
```csharp
services
.AddGraphQLServer()
.AddBlobStorageAssetCache(x =>
{
x.ContainerName = "your-container-name";
x.Client = new BlobServiceClient(
new Uri("https://yourblobstorage.blob.core.windows.net/"),
new DefaultAzureCredential());
})
```
## Custom `IAssetCache`
If you need a specific cache setup, you can make your own by implementing the `IAssetCache`
interface. This lets you decide how queries and configurations are cached according to your needs.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,22 @@ public void ConfigureServices(IServiceCollection services)
}
```

## Storage mechanisms
# Production Ready Persisted Queries
In transitioning your persisted query setup to production, simply setting up a persisted query file
isn't sufficient for a robust production environment. A key aspect of managing persisted queries at
scale involves version management and ensuring compatibility with your GraphQL schema. The client
registry is your go-to resource for this purpose.

The client registry simplifies the management of your GraphQL clients and their queries.
It allows for the storage and retrieval of persisted queries through their hashes but also ensures
that these queries are validated against the current schema on publish, preventing runtime errors
due to schema-query mismatches. Additionally, it supports versioning of your clients, allowing
seamless updates and maintenance without disrupting existing operations

Check out the [client registry documentation](/docs/bananacakepop/v2/apis/client-registry.md) for
more information.

# Other Storage mechanisms

Hot Chocolate supports two query storages for regular persisted queries.

Expand Down

0 comments on commit a7d2aef

Please sign in to comment.