# How to clear the Redis cache

Clear the Redis cache when cached data has gone stale - for example after a deploy, a configuration
change, or while troubleshooting. TurboStack runs [two Redis instances](sessions-and-cache.md), so it
matters which one you clear: the **cache** instance (`6379`) holds throwaway data, while the
**persistent** instance (`6378`) holds sessions and queues you do not want to lose.

## Clear the cache with the TurboStack CLI

`tscli redis clear` is the usual way. It runs `redis-cli flushall` against the **cache instance
(6379)**, clearing all of its databases. The **persistent instance (6378) is left untouched**, so
sessions and queued jobs survive.

```bash
tscli redis clear
```

Expect a short performance dip while the cache fills again.

> [!NOTE]
> This flushes *all* databases on the cache instance, so every application that caches on `6379` has its
> cache cleared - not just one. To clear a single site, use a targeted command below or your
> application's own cache flush.

## Clear a single database or the persistent instance

For finer control, use `redis-cli` directly (it connects to the cache instance on `6379` by default):

```bash
redis-cli -n 1 FLUSHDB        # clear only database 1 on the cache instance (6379)
redis-cli -p 6378 flushall    # clear the persistent instance - drops sessions and queues
```

> [!WARNING]
> The persistent instance (`6378`) holds sessions and queues. Clearing it logs users out and drops
> queued jobs - only do this deliberately.

## Prefer your application's own flush

When you only need to clear one application's cache, its own command is safest because it touches
just that application's keys. For example, Magento:

```bash
php bin/magento cache:flush
```

## After clearing

The cache rebuilds on the next requests, so the first hits are slower and load is briefly higher.
Warm the important pages by visiting them, or let your sitemap or a crawler do it, before judging the
result.

## Related

- [Use Redis for sessions and cache](sessions-and-cache.md)
- [Configure Redis](configure.md)
- [Inspect Redis with Redis Insight](inspect-with-redis-insight.md)
- [TurboStack CLI](../../api/cli.md)
- [Performance tuning](../../concepts/performance-tuning.md)
