Class: Mongo::QueryCache::Middleware

Inherits:
Object
  • Object
show all
Defined in:
build/ruby-driver-master/lib/mongo/query_cache.rb

Overview

Rack middleware that activates the query cache for each request.

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Instantiate the middleware.

Examples:

Create the new middleware.

Middleware.new(app)

Parameters:

  • app (Object)

    The rack application stack.



254
255
256
# File 'build/ruby-driver-master/lib/mongo/query_cache.rb', line 254

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object

Enable query cache and execute the request.

Examples:

Execute the request.

middleware.call(env)

Parameters:

  • env (Object)

    The environment.

Returns:

  • (Object)

    The result of the call.



266
267
268
269
270
271
272
# File 'build/ruby-driver-master/lib/mongo/query_cache.rb', line 266

def call(env)
  QueryCache.cache do
    @app.call(env)
  end
ensure
  QueryCache.clear
end