Sha256: ecb0ef9a7a103d6ed1ffd6284e62025b897b9fa16e3fb76d7661d84fefbe6800
Contents?: true
Size: 996 Bytes
Versions: 29
Compression:
Stored size: 996 Bytes
Contents
# typed: false # Copyright (c) 2015 Sqreen. All Rights Reserved. # Please refer to our terms for more information: https://www.sqreen.com/terms.html module Sqreen # dedicated local storage module SharedStorage unless RUBY_VERSION >= '2.3.0' def self.get(key) h = Thread.current[:sqreen_shared_storage] h[key] if h end end def self.set(key, obj) Thread.current[:sqreen_shared_storage] ||= {} Thread.current[:sqreen_shared_storage][key] = obj end def self.clear return unless Thread.current[:sqreen_shared_storage].is_a?(Hash) Thread.current[:sqreen_shared_storage].clear end def self.inc(value) set(value, (get(value) || 0) + 1) end def self.dec(value) set(value, (get(value) || 0) - 1) end end end # Change SharedStorage.get if ruby is actually newer require 'sqreen/shared_storage23' if RUBY_VERSION >= '2.3.0' class << Sqreen::SharedStorage alias [] get alias []= set end
Version data entries
29 entries across 29 versions & 1 rubygems