http_cache_handler

http_cache_handler

A Handler to handle caching within Crystal's HTTP layer. Built with the Cache Shard

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      http_cache_handler:
        github: jwaldrip/http_cache_handler
    
  2. Run shards install

Usage

You can use HTTPCacheHandler with any framework that accepts a Crystal HTTP::Handler. See the guides for this on popular frameworks such as Kemal, Amber, Lucky, Orion, and Grip. See the options below for how to configure with the various strategies.

require "http_cache_handler"

# In Memory
HTTPCacheHandler.new expires_in: 30.minutes

# With a file
HTTPCacheHandler.new expires_in: 30.minutes, path: "tmp/cache"

# With Redis
redis_client = Redis::Client.new
HTTPCacheHandler.new expires_in: 30.minutes, redis: redis_client

# With MemCached
memcached_client = Memcached::Client.new
HTTPCacheHandler.new expires_in: 30.minutes, memcached: memcached_client

# Null Store (for devlopment)
HTTPCacheHandler.new expires_in: 30.minutes, null: true

Contributing

  1. Fork it (https://github.com/your-github-user/http_cache_handler/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

Repository

http_cache_handler

Owner
Statistic
  • 3
  • 0
  • 0
  • 1
  • 0
  • over 4 years ago
  • June 14, 2020
License

MIT License

Links
Synced at

Thu, 07 Nov 2024 13:24:21 GMT

Languages