Class: Switchman::ShardAwareStatementCache

Inherits:
Object
  • Object
show all
Defined in:
lib/switchman/shard_aware_statement_cache.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(shard_category) ⇒ ShardAwareStatementCache

Returns a new instance of ShardAwareStatementCache.



7
8
9
10
11
# File 'lib/switchman/shard_aware_statement_cache.rb', line 7

def initialize(shard_category)
  self.extend Mutex_m
  self.__cache = {}
  self.shard_category = shard_category
end

Instance Attribute Details

#__cache=(value) ⇒ Object

Sets the attribute __cache

Parameters:

  • value

    the value to set the attribute __cache to.



4
5
6
# File 'lib/switchman/shard_aware_statement_cache.rb', line 4

def __cache=(value)
  @__cache = value
end

#shard_category=(value) ⇒ Object

Sets the attribute shard_category

Parameters:

  • value

    the value to set the attribute shard_category to.



4
5
6
# File 'lib/switchman/shard_aware_statement_cache.rb', line 4

def shard_category=(value)
  @shard_category = value
end

Instance Method Details

#[](key) ⇒ Object



13
14
15
# File 'lib/switchman/shard_aware_statement_cache.rb', line 13

def [](key)
  __cache[[key, Shard.current(shard_category).id]]
end

#[]=(key, value) ⇒ Object



17
18
19
# File 'lib/switchman/shard_aware_statement_cache.rb', line 17

def []=(key, value)
  __cache[[key, Shard.current(shard_category).id]] = value
end