Skip to content

v1.7.0

Compare
Choose a tag to compare
@github-actions github-actions released this 27 Mar 23:24
· 15 commits to master since this release

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)