Class: EventMachine::Bucketer::InMemory

Inherits:
Object
  • Object
show all
Includes:
Database::Hash, Base
Defined in:
lib/em-bucketer/in_memory.rb

Constant Summary collapse

BUCKET_THRESHOLD_SIZE_DEFAULT =
1000
BUCKET_MAX_AGE_DEFAULT =
3600

Instance Method Summary collapse

Methods included from Base

#add_item, #empty_bucket, #get_and_empty_bucket, #get_and_remove, #get_bucket, #on_bucket_full, #on_bucket_timeout, #setup

Constructor Details

#initialize(bucket_threshold_size: BUCKET_THRESHOLD_SIZE_DEFAULT, bucket_max_age: BUCKET_MAX_AGE_DEFAULT) ⇒ InMemory

Creates a new in memory Bucketer with the requested configurations

after which the on_bucket_full callback is called can remain before the on_bucket_timed_out is called

Parameters:

  • bucket_threshold_size (Integer) (defaults to: BUCKET_THRESHOLD_SIZE_DEFAULT)

    the max size of the bucket

  • bucket_max_age (Integer) (defaults to: BUCKET_MAX_AGE_DEFAULT)

    max number of seconds a bucket



20
21
22
23
# File 'lib/em-bucketer/in_memory.rb', line 20

def initialize(bucket_threshold_size: BUCKET_THRESHOLD_SIZE_DEFAULT, bucket_max_age: BUCKET_MAX_AGE_DEFAULT)
  setup(bucket_threshold_size, bucket_max_age)
  setup_db
end