redis_cache_store

A cache store implementation that stores data in Redis cache redis
0.2.3 released

Cache::RedisCacheStore

Crystal CI GitHub release

A cache store implementation that stores data in Redis

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      redis_cache_store:
        github: crystal-cache/redis_cache_store
    
  2. Run shards install

Usage

require "redis_cache_store"

It's important to note that Redis cache value must be string.

cache = Cache::RedisCacheStore(String, String).new(expires_in: 1.minute)
cache.fetch("today") do
  Time.utc.day_of_week
end

This assumes Redis was started with a default configuration, and is listening on localhost, port 6379.

You can connect to Redis by instantiating the Redis or Redis::PooledClient class.

If you need to connect to a remote server or a different port, try:

redis = Redis.new(host: "10.0.1.1", port: 6380, password: "my-secret-pw", database: "my-database")
cache = Cache::RedisCacheStore(String, String).new(expires_in: 1.minute, cache: redis)

Contributing

  1. Fork it (https://github.com/crystal-cache/redis_cache_store/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

redis_cache_store:
  github: crystal-cache/redis_cache_store
  version: ~> 0.2.3
License MIT
Crystal >= 0.35.0

Authors

Dependencies 2

  • cache~crystal-cache >= 0.12.0
    {'github' => 'crystal-cache/cache', 'version' => '>= 0.12.0'}
  • redis >= 2.6.0
    {'github' => 'stefanwille/crystal-redis', 'version' => '>= 2.6.0'}

Development Dependencies 1

  • ameba develop
    {'branch' => 'develop', 'github' => 'crystal-ameba/ameba'}

Dependents 1

Last synced .
search fire star recently