Sha256: 51fc08fabe1c7da79df8febf4d67f0bfc998a24dee216a72e697d3103fd96edd

Contents?: true

Size: 680 Bytes

Versions: 10

Compression:

Stored size: 680 Bytes

Contents

module ExpressTranslate
  class Database
    include ExpressTranslate
    require 'redis'
    
    def self.redis
      @redis = Redis.new(host: ExpressTranslate.config["connect"]["host"], port: ExpressTranslate.config["connect"]["port"], db: ExpressTranslate.config["connect"]["db"])
    end
    
    def self.set(key, obj)
      self.redis.set(key, obj.to_json)
    end
    
    def self.get(key)
      data = self.redis.get(key)
      data = JSON.parse(data) if data.present?
      data
    end
    
    def self.del(key)
      self.redis.del(key)
    end
    
    def self.clear
      self.redis.keys("*").each do |key|
        self.redis.del(key)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
express_translate-1.0.8 lib/express_translate/database_management.rb
express_translate-1.0.7 lib/express_translate/database_management.rb
express_translate-1.0.6 lib/express_translate/database_management.rb
express_translate-1.0.5 lib/express_translate/database_management.rb
express_translate-1.0.4 lib/express_translate/database_management.rb
express_translate-1.0.3 lib/express_translate/database_management.rb
express_translate-1.0.2 lib/express_translate/database_management.rb
express_translate-1.0.1 lib/express_translate/database_management.rb
express_translate-1.0 lib/express_translate/database_management.rb
express_translate-1.0.0.0 lib/express_translate/database_management.rb