# [Usage](../../../usage.md) > Clear expired cache

Use `cache:clear-expired` when the `database` or `file` cache store grows with stale entries. Unlike `cache:clear` (wipes everything), it deletes only entries whose expiration is past — framework signed payloads (`kfw_*`, see [Caching](caching.md)) and app entries alike.

---

## Method

### `php artisan cache:clear-expired {--store=*}`

#### Arguments

- **`--store`** *(optional, repeatable)*  
  Limit pruning to specific cache store names from `config/cache.php` (`stores`).  
  Example: `--store=database --store=file`.

#### What it does

- Scans every configured `database` + `file` store (or only `--store` ones).
- `database` driver: deletes rows where `expiration <= now()` in the store table (default `cache`).
- `file` driver: reads the 10-byte expiration header of each file, deletes past ones. `forever` entries (far-future timestamp) are kept; non-Laravel files are skipped.
- Prints `Expired cache cleared. DB deleted: X, File deleted: Y.`
- Other drivers (redis, memcached, array, ...) are ignored — they expire by themselves.

There is also an internal guard `ClearExpiredCache::clearExpiredCacheDaily($intervalSeconds = 86400)` (lock + last-run key) that prunes at most once per interval; the framework calls it opportunistically, you normally just run the command.

---

## Output

Console line with the two counters. Programmatic `ClearExpiredCache::clearExpiredCache($onlyStores)` returns `['db' => int, 'file' => int]`.

---

## Example

```bash
php artisan cache:clear-expired
php artisan cache:clear-expired --store=file
```

Schedule a daily prune:

```php
// routes/console.php
use Illuminate\Support\Facades\Schedule;

Schedule::command('cache:clear-expired')->daily();
```

## See also

- [Usage](../../../usage.md)
- [Caching](caching.md) — what the framework caches and its signatures
- [Installation](../../../installation.md) — `kfw:update` vs targeted cache commands
