connection_pool:Ruby的通用连接池

时间:2021-04-29 21:35:21
【文件属性】:
文件名称:connection_pool:Ruby的通用连接池
文件大小:15KB
文件格式:ZIP
更新时间:2021-04-29 21:35:21
Ruby connection_pool Ruby的通用连接池。 MongoDB有自己的连接池。 ActiveRecord有自己的连接池。 这是一个通用连接池,可以与任何组件(例如Redis,Dalli和其他Ruby网络客户端)一起使用。 用法 创建一个对象池以在Ruby应用程序中的光纤或线程之间共享: $memcached = ConnectionPool . new ( size : 5 , timeout : 5 ) { Dalli :: Client . new } 然后在您的应用程序中使用该池: $memcached . with do | conn | conn . get ( 'some-count' ) end 如果连接池中的所有对象都在使用中,则with将阻塞直到一个可用。 如果没有对象中可用:timeout秒, with将引发一个Timeout::Error 。
【文件预览】:
connection_pool-master
----.github()
--------workflows()
----connection_pool.gemspec(823B)
----lib()
--------connection_pool.rb(3KB)
--------connection_pool()
----Gemfile(68B)
----Changes.md(3KB)
----Rakefile(93B)
----LICENSE(1KB)
----test()
--------helper.rb(125B)
--------test_connection_pool_timed_stack.rb(3KB)
--------test_connection_pool.rb(13KB)
----README.md(4KB)
----.gitignore(33B)

网友评论