All Projects → printercu → pooled_redis

printercu / pooled_redis

Licence: MIT License
Simple way to access redis connections without global variables.

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to pooled redis

billiards
billiards physics
Stars: ✭ 37 (+105.56%)
Mutual labels:  pool
agroal
The natural database connection pool
Stars: ✭ 92 (+411.11%)
Mutual labels:  pool
not-only-mining-pool
new generation general mining pool in go
Stars: ✭ 31 (+72.22%)
Mutual labels:  pool
goroutine-pool
A simple goroutine pool which can create and release goroutine dynamically, inspired by fasthttp.
Stars: ✭ 31 (+72.22%)
Mutual labels:  pool
ethersocial-pool
Open EthersocialNetwork Mining Pool based off the sammy007's open-ethereum-pool
Stars: ✭ 19 (+5.56%)
Mutual labels:  pool
HiFramework.Unity
Based on component to manage project's core logic and module used in unity3d
Stars: ✭ 22 (+22.22%)
Mutual labels:  pool
xdagj
XDAGJ is an implementation of XDAG in Java. https://xdag.io
Stars: ✭ 81 (+350%)
Mutual labels:  pool
fastthreadpool
An efficient and lightweight thread pool
Stars: ✭ 27 (+50%)
Mutual labels:  pool
SimpleObjectPool
Simple thread-safe object pool in Objective-C
Stars: ✭ 13 (-27.78%)
Mutual labels:  pool
cryptonote-aeon-pool
AEON coin mining pool
Stars: ✭ 15 (-16.67%)
Mutual labels:  pool
node-redis-connection-pool
A node.js connection manager for Redis
Stars: ✭ 52 (+188.89%)
Mutual labels:  pool
gohive
🐝 A Highly Performant and easy to use goroutine pool for Go
Stars: ✭ 41 (+127.78%)
Mutual labels:  pool
arikado gridcoin pool
Simple gridcoin pool
Stars: ✭ 20 (+11.11%)
Mutual labels:  pool
node-screenlogic
Pentair ScreenLogic Javascript library using Node.JS
Stars: ✭ 38 (+111.11%)
Mutual labels:  pool
charnapool
High performance Node.js (with native C addons) mining pool for Cryptonote based coins, optimized for Charnacoin.
Stars: ✭ 25 (+38.89%)
Mutual labels:  pool
mysql-connection-pool-manager
This is a mySQL Connection Pool Manager wrapper powered by mysqljs/mysql and allows for intelligent management & load balancing mysql connection pools.
Stars: ✭ 15 (-16.67%)
Mutual labels:  pool
dotnet-design-patterns-samples
The samples of .NET design patterns
Stars: ✭ 25 (+38.89%)
Mutual labels:  pool
nodejs-poolController
An application to control pool equipment from various manufacturers.
Stars: ✭ 162 (+800%)
Mutual labels:  pool
simple-pool
#NVJOB Simple Pool. Pool for optimizing object loading. Unity Asset.
Stars: ✭ 16 (-11.11%)
Mutual labels:  pool
swoole-postgresql-doctrine-driver
🔌 A Doctrine DBAL Driver implementation on top of Swoole Coroutine PostgreSQL client
Stars: ✭ 15 (-16.67%)
Mutual labels:  pool

PooledRedis

Gem Version Build Status

Simple way to access redis connections without global variables.

Provides Rails.redis_pool & Rails.redis methods and configuration via database.yml. You can add this methods to custom modules.

Installation

Add this line to your application's Gemfile:

gem 'pooled_redis'

Usage

  • Add redis section to your database.yml with options supported by Redis.new
development:
  redis:
    db: 2
production:
  redis:
    url: 'redis://mymaster'
    sentinels:
      - host: host
      - host: other
  • You can also provide pool & timeout values for ConnectionPool.
  • Use debug: true to set redis logger to Rails.logger.
  • Pass namespace if you want to use redis-namespace.
  • Use Rails.redis_pool & Rails.redis method.

PooledRedis uses ConnectionPool for pooling connections. .redis returns proxy object that checkouts connection for every method call. So you may want to avoid it for bulk operations.

Rails.cache configuration & Redis::Store support

PooledRedis provides configuration of Rails.cache via database.yml. To enable this add following to your config/application.rb (inside Application class):

PooledRedis.setup_rails_cache(self)

And cache sections to database.yml:

development:
  cache:
    adapter: redis_store
    db: 3
    expires_in: 3600

production:
  cache:
    adapter: redis_store
    url: 'redis://mycachemaster'
    sentinels:
      - host: host
      - host: other

# You can also use other adapters:
test:
  cache:
    adapter: null_store

You need to add gem 'redis-activesupport' to your Gemfile. It supports only new version of Redis::Store with support of ConnectionPool (currently it's only available in master: gem 'redis-activesupport', '~> 4.0.0', github: 'redis-store/redis-activesupport', ref: 'd09ae04').

Custom modules or without rails

  • Extend or include PooledRedis module.
  • Override redis_config method to return valid configuration.
  • Use redis_pool & redis methods.
class Storage
  extend PooledRedis

  class << self
    def redis_config
      read_your_yaml.symbolize_keys
    end
  end

  # ...

  def save
    self.class.redis.set id, to_json
  end
end

Storage.redis_pool.with { |r| r.get :some_key }
Storage.redis.get :some_key

Advanced usage

You can return hash containing :block from redis_config. This block will be used as a block to instantiate connection in ConnectionPool.

Licence

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].