https://github.com/databasecleaner/database_cleaner-redis
https://github.com/databasecleaner/database_cleaner-redis
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/databasecleaner/database_cleaner-redis
- Owner: DatabaseCleaner
- License: mit
- Created: 2016-05-16T01:53:16.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2022-12-31T03:05:09.000Z (about 3 years ago)
- Last Synced: 2025-08-09T20:21:13.703Z (7 months ago)
- Language: Ruby
- Size: 1.08 MB
- Stars: 5
- Watchers: 5
- Forks: 8
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Database Cleaner Adapter for Redis
[](https://travis-ci.org/DatabaseCleaner/database_cleaner-redis)
[](https://codeclimate.com/github/DatabaseCleaner/database_cleaner-redis)
[](https://codecov.io/gh/DatabaseCleaner/database_cleaner-redis)
Clean your Redis databases with Database Cleaner.
See https://github.com/DatabaseCleaner/database_cleaner for more information.
## Installation
```ruby
# Gemfile
group :test do
gem 'database_cleaner-redis'
end
```
## Supported Strategies
The redis adapter only has one strategy: the deletion strategy.
## Strategy configuration options
`:only` and `:except` may take a list of strings to be passed to [`keys`](https://redis.io/commands/keys)):
```ruby
# Only delete the "users" key, and keys that start with "cache".
DatabaseCleaner[:redis].strategy = :deletion, only: ["users", "cache*"]
# Delete all keys except the "users" key.
DatabaseCleaner[:redis].strategy = :deletion, except: ["users"]
```
## Adapter configuration options
`#db` defaults to `Redis.new`, but can be specified manually in a few ways:
```ruby
# Redis URI string:
DatabaseCleaner[:redis].db = "redis://localhost:6379/0"
# Redis connection object:
DatabaseCleaner[:redis].db = Redis.new(url: "redis://localhost:6379/0")
# Back to default:
DatabaseCleaner[:redis].db = :default
```
## COPYRIGHT
See [LICENSE](LICENSE) for details.