class Redis::TimeSeries::DuplicatePolicy

Duplication policies can be applied to a time series in order to resolve conflicts when adding data that already exists in the series.

@see oss.redislabs.com/redistimeseries/master/configuration/#duplicate_policy

Constants

VALID_POLICIES

Attributes

policy[R]

Public Class Methods

new(policy) click to toggle source
# File lib/redis/time_series/duplicate_policy.rb, line 20
def initialize(policy)
  policy = policy.to_s.downcase.to_sym
  if VALID_POLICIES.include?(policy)
    @policy = policy
  else
    raise UnknownPolicyError, "#{policy} is not a valid duplicate policy"
  end
end

Public Instance Methods

==(other) click to toggle source
# File lib/redis/time_series/duplicate_policy.rb, line 37
def ==(other)
  return policy == other.policy if other.is_a?(self.class)
  policy == self.class.new(other).policy
end
to_a(cmd = 'DUPLICATE_POLICY') click to toggle source
# File lib/redis/time_series/duplicate_policy.rb, line 29
def to_a(cmd = 'DUPLICATE_POLICY')
  [cmd, policy]
end
to_s(cmd = 'DUPLICATE_POLICY') click to toggle source
# File lib/redis/time_series/duplicate_policy.rb, line 33
def to_s(cmd = 'DUPLICATE_POLICY')
  to_a(cmd).join(' ')
end