jeredis 0.1.0-java

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1b09dd39a036ccaf7ecba0082c9a880caafa51db
4
+ data.tar.gz: aebffb9dc540396bb997bb5b7f030f2a43c08f95
5
+ SHA512:
6
+ metadata.gz: cc2aa202b4ea5c47aebe7df5a50ef24800322fc66c720c6093676bf54dcccb3760853d5f1f1ea72d2dfba6ec10cf72a8d9ccf1ebc0317497a39eb77b91ffbc00
7
+ data.tar.gz: 3f089fa26cb7d490c36818678bbbe7cde3dcfb9977ccdb429a9518ec8cb84f203ae1a3446cbd0730bae6e260f2986786ec6cb31889a2a54aa46a715889ee0b01
Binary file
Binary file
@@ -0,0 +1,57 @@
1
+ require 'java'
2
+ require 'ext/jedis'
3
+ require 'ext/commons-pool2'
4
+
5
+ module Jeredis
6
+ class Pool
7
+ java_import Java::RedisClientsJedis::JedisPool
8
+ java_import Java::RedisClientsJedis::JedisPoolConfig
9
+
10
+ attr_reader :pool
11
+
12
+ # Initialize Jedis pool
13
+ # @param [Hash] opts Connection options
14
+ #
15
+ # @option options [String] :host ("localhost") Hostname or IP address.
16
+ # @option options [Integer] :port (6379) Redis server port.
17
+ # @option options [Integer] :timeout (5000) Connection timeout in ms.
18
+ # @option options [String] :password Redis server password.
19
+ # @option options [Integer] :db Redis database number.
20
+ # @option options [Integer] :min_idle Min idle threads in a pool.
21
+ # @option options [Integer] :max_idle Max idle threads in a pool.
22
+ # @option options [Integer] :max_total Max total active threads.
23
+ def initialize(options = {})
24
+ opts = options.dup
25
+ host = opts.delete(:host) || 'localhost'
26
+ port = opts.delete(:port) || 6379
27
+ timeout = opts.delete(:timeout) || 5000
28
+ password = opts.delete(:password)
29
+ db = opts.delete(:db) || 0
30
+
31
+ config = JedisPoolConfig.new
32
+ config.minIdle = opts.fetch(:min_idle) if opts[:min_idle]
33
+ config.maxIdle = opts.fetch(:max_idle) if opts[:max_idle]
34
+ config.maxTotal = opts.fetch(:max_total) if opts[:max_total]
35
+ config.block_when_exhausted = false
36
+ config.max_wait_millis = timeout
37
+ config.jmx_enabled = true
38
+
39
+ @pool = JedisPool.new(config, host, port, timeout, password, db)
40
+ end
41
+
42
+ def with
43
+ conn = @pool.resource
44
+ yield conn
45
+ ensure
46
+ conn.close if conn
47
+ end
48
+
49
+ def pipelined
50
+ with do |j|
51
+ pipeline = j.pipelined
52
+ response = yield pipeline
53
+ pipeline.sync_and_return_all.to_a
54
+ end
55
+ end
56
+ end
57
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jeredis
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: java
6
+ authors:
7
+ - Konstantin Shabanov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-04-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: 10.0.0
19
+ name: rake
20
+ prerelease: false
21
+ type: :development
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 10.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ name: pry
34
+ prerelease: false
35
+ type: :development
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Jedis wrapper
42
+ email:
43
+ - etehtsea@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - lib/ext/commons-pool2.jar
49
+ - lib/ext/jedis.jar
50
+ - lib/jeredis.rb
51
+ homepage: http://github.com/etehtsea/jeredis
52
+ licenses:
53
+ - MIT
54
+ metadata: {}
55
+ post_install_message:
56
+ rdoc_options: []
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubyforge_project:
71
+ rubygems_version: 2.4.8
72
+ signing_key:
73
+ specification_version: 4
74
+ summary: Jedis wrapper
75
+ test_files: []