# Toggling Spring Cache at Runtime with a Custom Cache Manager

DevFeed: [Toggling Spring Cache at Runtime with a Custom Cache Manager](<https://devfeed.tech/articles/toggable-cache-27322.md>)

Original publisher: [Read original article](<https://blog.pchudzik.com/202001/toggable-cache/>)

Published: 2020-01-09T00:00:00Z

Content type: tutorial

Language: en

Sources: [Paweł Chudzik](<https://devfeed.tech/sources/pawe-chudzik.md>)

Topics: [Cache](<https://devfeed.tech/topics/cache.md>), [Caching](<https://devfeed.tech/topics/caching.md>), [Redis](<https://devfeed.tech/topics/redis.md>), [configuration](<https://devfeed.tech/topics/configuration.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [cache](<https://devfeed.tech/tags/cache.md>), [caching](<https://devfeed.tech/tags/caching.md>), [code](<https://devfeed.tech/tags/code.md>), [configuration](<https://devfeed.tech/tags/configuration.md>), [metrics](<https://devfeed.tech/tags/metrics.md>), [redis](<https://devfeed.tech/tags/redis.md>)

## AI overview

This proof-of-concept article describes how to enable or disable Spring caching at runtime using a custom cache manager. The manager delegates to Redis when caching is enabled and bypasses it when disabled, allowing behavior to be tested against production-like traffic and metrics.

## Source excerpt

Sometimes it's good to have an option to try something out on the live environment. Checking things against production like traffic is the most reliable way to gather real-life metrics. In this post, I'm going to try and set up spring cache with a toggle. It'll be possible to turn it off and on during application runtime possibly using external toggle service. Read more