29 lines
620 B
Ruby
29 lines
620 B
Ruby
module Qwaiter
|
|
module Counter
|
|
mattr_accessor :connection
|
|
|
|
# mainly for testing purposes
|
|
def self.set(key, value)
|
|
connection.set(key, value)
|
|
end
|
|
|
|
def self.get(key)
|
|
connection.get(key, quiet: true).to_i
|
|
end
|
|
|
|
def self.incr(key, options = {})
|
|
options[:initial] ||= 0
|
|
connection.incr(key, options)
|
|
end
|
|
|
|
def self.decr(key, options = {})
|
|
connection.decr(key, options)
|
|
end
|
|
end
|
|
end
|
|
|
|
# use the connection from couchbase-structures/documents
|
|
# will be overwritten in the specs since flushing the real
|
|
# thing is difficult
|
|
Qwaiter::Counter.connection = $cb
|