Class: RedisCounters::UniqueValuesLists::Expirable

Inherits:
Blocking show all
Defined in:
lib/redis_counters/unique_values_lists/expirable.rb

Overview

Список уникальных значений, с возможностью expire отдельных элементов.

На основе сортированного множества. redis4you.com/code.php?id=010

На основе механизма оптимистических блокировок. смотри Optimistic locking using check-and-set: redis.io/topics/transactions

Особенности:

* Expire - 

Пример:

counter = RedisCounters::UniqueValuesLists::Expirable.new(redis,

:counter_name => :sessions,
:value_keys   => [:session_id],
:expire       => 10.minutes

)

counter << session_id: 1 counter << session_id: 2 counter << session_id: 3, expire: :never

counter.data > [1, 2, 3]

# after 10 minutes

counter.data > [3]

counter.has_value?(session_id: 1) false

Constant Summary collapse

DEFAULT_AUTO_CLEAN_EXPIRED =
true
DEFAULT_VALUE_TIMEOUT =
:never
NEVER_EXPIRE_TIMESTAMP =
0

Constants inherited from Blocking

Blocking::PARTITIONS_LIST_POSTFIX

Constants inherited from BaseCounter

BaseCounter::KEY_DELIMITER, BaseCounter::VALUE_DELIMITER

Instance Attribute Summary

Attributes inherited from BaseCounter

#options, #params, #redis

Instance Method Summary collapse

Methods inherited from Blocking

#delete_partition_direct!, #has_value?

Methods inherited from Base

#has_value?

Methods included from ClusterizeAndPartitionize

#data, #delete_all!, #delete_all_direct!, #delete_partition_direct!, #delete_partitions!, #partitions

Methods inherited from BaseCounter

create, #initialize, #name, #process

Constructor Details

This class inherits a constructor from RedisCounters::BaseCounter

Instance Method Details

#clean_expired(cluster = {}) ⇒ Object

Public: Производит принудительную очистку expired - значений.

cluster - Hash - параметры кластера, если используется кластеризация.

Returns nothing.



61
62
63
64
# File 'lib/redis_counters/unique_values_lists/expirable.rb', line 61

def clean_expired(cluster = {})
  set_params(cluster)
  internal_clean_expired
end