Files
spring-boot-demo/redis/docs/10-production-checklist.md

2.3 KiB

Home | Prev: Redis as the Spring cache

10. Production checklist

Each line points at the chapter where the reason was demonstrated. Items marked not run here are general advice this repository does not exercise.

Serialization

  • Keys go through StringRedisSerializer, in every template, in every service that shares the Redis (chapters 2 and 3).
  • Values are JSON with a serializer you chose, not the JDK default (chapter 4).
  • If you use the generic Jackson serializer, it has a PolymorphicTypeValidator allow-list, not enableUnsafeDefaultTyping() (chapter 4).
  • You are on GenericJacksonJsonRedisSerializer / JacksonJsonRedisSerializer, not the deprecated Jackson2 classes (chapter 4).
  • Changing a serializer on a Redis that already has data has a migration or a new key prefix (not run here).

Expiry

  • Every cache and session key has a TTL, and refreshes re-supply it (chapter 8).
  • @RedisHash entities with timeToLive either have keyspace events on or you accept the leftover index entries (chapter 6).
  • Nothing correctness-critical depends on receiving an expiry event (chapters 6 and 7).
  • With a custom RedisCacheConfiguration, the TTL is in the bean (chapter 9).

Messaging

  • Pub/Sub is used only for messages you can afford to lose (chapter 7).

Operations (not run here)

  • KEYS * is fine in these transcripts because the keyspace has a handful of keys. On a real server it is O(N) and blocks it; use SCAN.
  • Redis requires authentication and is not reachable from the internet. Anyone who can write to it can choose the class your generic serializer instantiates (chapter 4).
  • Connection and command timeouts are set deliberately, not left at defaults.
  • Do not point these tests at a production Redis: LocalRedis exists to stop that, because the tests call FLUSHALL.

Home | Prev: Redis as the Spring cache