Method: PEROBS::Cache#initialize

Defined in:
lib/perobs/Cache.rb

#initialize(bits = 16) ⇒ Cache

Create a new Cache object.

Parameters:

  • bits (Integer) (defaults to: 16)

    Number of bits for the cache index. This parameter heavilty affects the performance and memory consumption of the cache.



43
44
45
46
47
48
49
50
# File 'lib/perobs/Cache.rb', line 43

def initialize(bits = 16)
  @bits = bits
  # This mask is used to access the _bits_ least significant bits of the
  # object ID.
  @mask = 2 ** bits - 1
  # Initialize the read and write cache
  reset
end