Method: Parse::Query#cache

Defined in:
lib/parse/query.rb

#cacheBoolean, Integer

Set whether this query should be cached and for how long. This parameter is used to cache queries when using Middleware::Caching. If the caching middleware is configured, all queries will be cached for the duration allowed by the cache, and therefore some queries could return cached results. To disable caching and cached results for this specific query, you may set this field to false. To specify the specific amount of time you want this query to be cached, set a duration (in number of seconds) that the caching middleware should cache this request.

Examples:

# find all users with name "Bob"
query = Parse::Query.new("_User", :name => "Bob")

query.cache = true # (default) cache using default cache duration.

query.cache = 1.day # cache for 86400 seconds

query.cache = false # do not cache or use cache results

# You may optionally pass this into the constraint hash.
query = Parse::Query.new("_User", :name => "Bob", :cache => 1.day)

Returns:

  • if set to true or false on whether it should use the default caching length set when configuring Middleware::Caching.

  • if set to a number of seconds to cache this specific request with the Middleware::Caching.



152
# File 'lib/parse/query.rb', line 152

attr_accessor :table, :client, :key, :cache, :use_master_key, :session_token