https://github.com/redding/hella-redis
It's-a hella-redis
https://github.com/redding/hella-redis
connection-pool redis redis-client
Last synced: about 2 months ago
JSON representation
It's-a hella-redis
- Host: GitHub
- URL: https://github.com/redding/hella-redis
- Owner: redding
- License: mit
- Created: 2013-03-02T04:05:48.000Z (over 13 years ago)
- Default Branch: main
- Last Pushed: 2021-06-14T14:36:59.000Z (about 5 years ago)
- Last Synced: 2026-02-28T11:49:38.602Z (4 months ago)
- Topics: connection-pool, redis, redis-client
- Language: Ruby
- Size: 38.1 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# HellaRedis
It's-a hella-redis!
This gem is a wrapper that builds a connection pool of redis connections. It also provides spies and test mode behavior to ease testing redis interactions.
## Usage
```ruby
# create
@redis =
HellaRedis.new(
timeout: 1,
size: 5,
redis_ns: "hella-redis-test",
driver: "ruby",
url: "redis://localhost:6379/0"
) # => HellaRedis:ConnectionPool instance
# it's actually a pool of connections
@redis.connection do |connection|
# checks out a connection so you can do something with it
# will check it back in once the block has run
end
```
### Test Mode
```ruby
ENV["HELLA_REDIS_TEST_MODE"] = "yes" # set to anything "truthy"
@redis_spy =
HellaRedis.new({
timeout: 1,
size: 5,
redis_ns: "hella-redis-test",
driver: "ruby",
url: "redis://localhost:6379/0"
}) # => HellaRedis::ConnectionPoolSpy instance
@redis_spy.connection do |connection|
connection # => HellaRedis::ConnectionSpy instance
connection.info
end
@redis_spy.calls.size # => 1
@redis_spy.calls.first.tap do |call|
call.command # => :info
call.args # => nil
call.block # => nil
end
@redis_spy.connection_calls.size # => 1
@redis_spy.connection_calls.first.tap do |connection_call|
connection_call.block # => block instance
end
Assert.stub(@redis_spy.connection_spy, :get).with("some-key"){ "some-value" }
value = @redis_spy.connection do |connection|
connection.get("some_key")
end
assert_that("some-value").equals(value)
@redis_spy.calls.size # => 1 (unchanged b/c we stubbed the :get method)
```
## Installation
Add this line to your application's Gemfile:
gem "hella-redis"
And then execute:
$ bundle
Or install it yourself as:
$ gem install hella-redis
## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Added some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request