Name | Modified | Size | Downloads / Week |
---|---|---|---|
Parent folder | |||
README.md | 2024-03-27 | 1.6 kB | |
v1.7.0 source code.tar.gz | 2024-03-27 | 185.0 kB | |
v1.7.0 source code.zip | 2024-03-27 | 267.2 kB | |
Totals: 3 Items | 453.8 kB | 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.
:::ruby
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.
:::ruby
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.
:::ruby
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)