class Locking def self.lock_on(key, wait:, attempts:, &block) counter = Kredis.counter(key, expires_in: wait) counter.increment if counter.value > attempts yield end end end