Releases: graphiti-api/graphiti
Releases · graphiti-api/graphiti
v1.7.6
v1.7.5
v1.7.4
v1.7.3
v1.7.2
v1.7.1
v1.7.0
1.7.0 (2024-03-27)
Features
• Add support for caching renders in Graphiti, and better support using etags and stale? in the controller (#424) (8bae50a)
Read the PR for more detail, but in short, start using stale?
in your controllers, as etag
and updated_at
, cache_key
, and cache_key_with_version
methods have been added to the resource.
class EmployeesController < ApplicationController
def index
@employees = Employees.all(params)
respond_with @employees if stale?(@employees)
end
end
Also you can now cache the rendering of a graphiti resource.
Graphiti.configure do |c|
c.cache_rendering = Rails.env.production?
# c.debug = true
# with debug enabled extra information about caching will be output
end
Graphiti.cache = ::Rails.cache # or whatever cache you want to use that conforms to the same typical cache interface with .read, .write. fetch, etc.
class EmployeesController < ApplicationResource
cache_resource, expires_in: 1.week
end
With the above the actual json-rendering will be cached, often improving response time dramatically. (All render cache keys are namespaced and start with graphiti:render/
, in case you're digging in your cache and wanting to see what's what)