Module YARD::Server::StaticCaching
In: lib/yard/server/static_caching.rb

Implements static caching for requests.

@see Router Router documentation for "Caching"

Methods

Public Instance methods

Called by a router to return the cached object. By default, this method performs disk-based caching. To perform other forms of caching, implement your own +check_static_cache+ method and mix the module into the Router class.

Note that caching does not occur here. This method simply checks for the existence of cached data. To actually cache a response, see {Commands::Base#cache}.

@example Implementing In-Memory Cache Checking

  module MemoryCaching
    def check_static_cache
      # $memory_cache is filled by {Commands::Base#cache}
      cached_data = $memory_cache[request.path]
      if cached_data
        [200, {'Content-Type' => 'text/html'}, [cached_data]]
      else
        nil
      end
    end
  end

  class YARD::Server::Router; include MemoryCaching; end

@return [Array(Numeric,Hash,Array)] the Rack-style response @return [nil] if no cache is available and routing should continue @see Commands::Base#cache

[Validate]