Skip to content

Commit

Permalink
add section to README about creating a reaper thread
Browse files Browse the repository at this point in the history
  • Loading branch information
ttstarck committed Jul 27, 2024
1 parent 2148a28 commit 28e9760
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,22 @@ cp = ConnectionPool.new { Redis.new }
cp.reap(300) { |conn| conn.close } # Reaps connections that have been idle for 300 seconds (5 minutes).
```

### Reaper Thread

You can start your own reaper thread to reap idle connections in the ConnectionPool instance on a regular interval.

```ruby
cp = ConnectionPool.new { Redis.new }

# Start a reaper thread to reap connections that have been idle for 300 seconds (5 minutes).
Thread.new do
loop do
cp.reap(300) { |conn| conn.close }
sleep 300
end
end
```

## Current State

There are several methods that return information about a pool.
Expand Down

0 comments on commit 28e9760

Please sign in to comment.