Shard Detail

redis_cache_store v0.4.1

A cache store implementation that stores data in Redis
crystal cache redis

Install & Use

Add the following code to your project's shard.yml under:

dependencies to use in production
- OR -
development_dependencies to use in development

  github: crystal-cache/redis_cache_store



Crystal CI GitHub release

A cache store implementation that stores data in Redis.

This shard using jgaskins/redis as Redis client library.

If you're looking for an implementation that uses stefanwille/crystal-redis check


  1. Add the dependency to your shard.yml:

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


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, namespace: "myapp-cache")

# Fetches data from the Redis, using "myapp-cache:today" key. If there is data in
# the Redis with the given key, then that data is returned.
# If there is no such data in the Redis (a cache miss or expired), then
# block will be written to the Redis under the given cache key, and that
# return value will be returned.
cache.fetch("today") do
# => Wednesday

No namespace is set by default. Provide one if the Redis cache server is shared with other apps:

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::Client class.

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

redis_uri = URI.parse("rediss://:my-secret-pw@")
redis = redis_uri)
cache = Cache::RedisCacheStore(String, String).new(expires_in: 1.minute, cache: redis)


  1. Fork it (
  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