lib/sfn/cache.rb in sfn-3.0.30 vs lib/sfn/cache.rb in sfn-3.0.32

- old
+ new

@@ -1,8 +1,8 @@ -require 'digest/sha2' -require 'thread' -require 'sfn' +require "digest/sha2" +require "thread" +require "sfn" module Sfn # Data caching helper class Cache class << self @@ -14,13 +14,13 @@ def configure(type, args = {}) type = type.to_sym case type when :redis begin - require 'redis-objects' + require "redis-objects" rescue LoadError - $stderr.puts 'The `redis-objects` gem is required for Cache support!' + $stderr.puts "The `redis-objects` gem is required for Cache support!" raise end @_pid = Process.pid Redis::Objects.redis = Redis.new(args) when :local @@ -166,11 +166,11 @@ when :value Redis::Value.new(full_name, {:marshal => true}.merge(args)) when :lock Redis::Lock.new(full_name, {:expiration => 60, :timeout => 0.1}.merge(args)) when :stamped - Stamped.new(full_name.sub("#{key}_", '').to_sym, get_redis_storage(:value, full_name), self) + Stamped.new(full_name.sub("#{key}_", "").to_sym, get_redis_storage(:value, full_name), self) else raise TypeError.new("Unsupported caching data type encountered: #{data_type}") end end @@ -191,11 +191,11 @@ when :value LocalValue.new when :lock LocalLock.new(full_name, {:expiration => 60, :timeout => 0.1}.merge(args)) when :stamped - Stamped.new(full_name.sub("#{key}_", '').to_sym, get_local_storage(:value, full_name), self) + Stamped.new(full_name.sub("#{key}_", "").to_sym, get_local_storage(:value, full_name), self) else raise TypeError.new("Unsupported caching data type encountered: #{data_type}") end end @@ -225,11 +225,11 @@ # # @param key [Object] # @param val [Object] # @note this will never work, thus you should never use it def []=(key, val) - raise 'Setting backend data is not allowed' + raise "Setting backend data is not allowed" end # Check if cache time has expired # # @param key [String, Symbol] value key @@ -261,10 +261,10 @@ begin self[lock_name].lock do yield end rescue => e - if e.class.to_s.end_with?('Timeout') + if e.class.to_s.end_with?("Timeout") raise if raise_on_locked else raise end end