Created
January 13, 2015 15:56
-
-
Save raa0121/dbdd5e0b797cc286fb6c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
require 'java' | |
require 'singleton' | |
import 'redis.clients.jedis.Jedis' | |
import 'redis.clients.jedis.JedisPool' | |
import 'redis.clients.jedis.JedisPoolConfig' | |
module Rukkit | |
class Redis | |
class << self | |
include Singleton | |
def initialize(db = 666) | |
@pool = JedisPool.new(JedisPoolConfig.new, "localhost") | |
@jedis = @pool.getResource | |
@connection = @jedis.select(db) | |
end | |
def connect(db) | |
begin | |
@jedis.select(db) | |
rescue Exception => e | |
puts e.message | |
puts e.backtrace.inspect | |
else | |
# other exception | |
ensure | |
# always executed | |
end | |
end | |
def set(key, value) | |
begin | |
@jedis.set(key, value) | |
rescue Exception => e | |
puts e.message | |
puts e.backtrace.inspect | |
else | |
# other exception | |
ensure | |
# always executed | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment