In my laravel application, I use Redis to store some cache (e.g. the list of items to show on the front page). I always access Redis through the Facade: Illuminate\Support\Facades\Redis
.
I created a different Redis database for testing (1
instead of 0
), but I also need to reset it after each test, so that the test never gets data from a previous test.
Is there an efficient way to create this behaviour?
I tried to implement it using the @before
annotation:
/**
* @before
*/
public function prepareForTesting() {
Redis::flushdb();
}
But I get the error: Cannot use 'FLUSHDB' over clusters of connections.
Any ideas?