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)?

[View source]

Instance Method Detail

def debug : Bool #

[View source]
def expires : Time::Span | Nil #

[View source]
def file : String | Nil #

[View source]
def intercept(chain) #

[View source]
def path : String #

[View source]