class Halite::Cache

Overview

Cache feature use for caching HTTP response to local storage to speed up in developing stage.

It has the following options:

With debug mode, cached response it always included some headers information:

Halite.use("cache").get "http://httpbin.org/anything"     # request a HTTP
r = Halite.use("cache").get "http://httpbin.org/anything" # request from local storage
r.headers                                                 # => {..., "X-Halite-Cached-At" => "2018-08-30 10:41:14 UTC", "X-Halite-Cached-By" => "Halite", "X-Halite-Cached-Expires-At" => "2018-08-30 10:41:19 UTC", "X-Halite-Cached-Key" => "2bb155e6c8c47627da3d91834eb4249a"}}

Defined in:

halite/features/cache.cr

Constant Summary

DEFAULT_PATH = "/tmp/halite/cache/"

Constructors

Instance Method Summary

Instance methods inherited from class Halite::Feature

intercept(chain : Halite::Feature::Chain) : Halite::Feature::Chain intercept, request(request : Halite::Request) : Halite::Request request, response(response : Halite::Response) : Halite::Response response

Constructor methods inherited from class Halite::Feature

new(**options) new

Constructor Detail

def self.new(**options) #

return a new Cache instance

Accepts argument:

  • debug: Bool
  • path: String
  • expires: (Int32 | Time::Span)?

Instance Method Detail

def debug : Bool #

def expires : Time::Span? #

def file : String? #

def intercept(chain) #

def path : String #