Redis

Open Redis Client of your Heroku app

heroku redis:cli -a yourapp --confirm yourapp

INFO command to see status of your Redis.

> info

Some infos you should pay attention:

used_memory:3976008
used_memory_human:3.79M

keyspace_hits:2270
keyspace_misses:1229

You could also get these info separately by info memory or info stats.

Calculate your cache hit rate:

keyspace_hits / (keyspace_hits + keyspace_misses)

Aim for 90%.

All items outputed from INFO command, please refer to here.

And you can also compress what got saved into Redis to save memory!

config.cache_store = :redis_cache_store, {
  url: ENV.fetch("REDIS_URL"),
  namespace: "cache",
  expires_in: 604800, # 7 days
  compress: true,
  compress_threshold: 64.kilobytes,
  # compress things > 64K
}

Commands to learn

  • GET
  • MGET
  • RPOPLPUSH
  • SETEX
  • LREM
  • MULTI SADD LPUSH
  • EVALSHA
  • MULTI EXPIRE HGET
  • SET
  • PUBLISH
  • DEL
  • HMSET EXPIRE
  • INCR EXPIRE
  • MULTI INCR EXPIRE
  • SCAN
  • TIME
  • MULTI SET INCR
  • HGET
  • MULTI SREM SCARD