Appendix
Concepts

Concepts

Caching

In short Hydra's caching provides a way to read data stored in a cache automatically, instead of consuming data from the actual downstream APIs. Thus access to payload is significantly faster if a corresponding payload exists in cache for a given query.

ℹ️

Cache can be bypassed by passing the x-hydra-skip-cache header with a value of true to the request.

Cache Keys Segmentation

Keys are segmented in the cache to permit caching in different contexts (e.g.: queries cached for a given user, queries cached with specific variables)

Cache keys contains informations about the query, respectively

  • user:query:variables for authenticated queries
  • query:variables for public queries

Composites

  • user is a hash of a given authenticated user identifier
  • query is a hash of a given GraphQL query
  • variables is a hash of GraphQL query variables set

Cache Invalidation

Hydra's cache invalidation provides a way to invalidate a given cache entry, or a set of cache entries, based on schema types.

Assuming a mutation that creates a new Book in the system, owned by a given User type, if the mutation returns the User type with its id field, then Hydra will automatically invalidate the cached records and every associated records from the cache.

Rate Limiting

Hydra's rate limiting provides a way to limit the number of requests to a given API in a given time frame. This is defined by a rate limit policy, which is a set of rules that define the number of requests that can be made in a given time frame.

For instance, you can define a policy to protect a given endpoint with a rate limit of 100 requests per minute.

©2024 Authdog