Add cache per query.

This commit is contained in:
2022-12-20 10:26:05 +00:00
parent edc695fe2b
commit 32091fc8cd
5 changed files with 492 additions and 28 deletions
+17
View File
@@ -9,6 +9,7 @@ Ps. It's Hasura friendly.
- [Features](#features)
- [Usage example](#usage-example)
- [Environment variables](#environment-variables)
- [Cache](#cache)
- [Example reader code](#example-reader-code)
- [Working with results](#working-with-results)
@@ -37,6 +38,22 @@ Therefore, I present you the simple client to which you can copy & paste your gr
* `RETRIES_NUMBER` - Number of retries: Default: `1`
* `RETRIES_DELAY` - Delay in retries in milliseconds. Default: `250`
### Cache
You have two options to enable the cache:
* Use `GRAPHQL_CACHE` environment variable which will enable the cache globally. It may be desired if you want to use the cache for all queries.
* Add `gqlcache: true` header for your query which will enable the cache for this query only with `GRAPHQL_CACHE_TTL` TTL.
Example:
```go
headers := map[string]interface{}{
...
"gqlcache": true,
}
```
### Example reader code