Class: ActiveRecord::ConnectionAdapters::NuoDBAdapter::StatementPool

Inherits:
ConnectionAdapters::StatementPool
  • Object
show all
Defined in:
lib/active_record/connection_adapters/nuodb_adapter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection, max) ⇒ StatementPool

Returns a new instance of StatementPool.



193
194
195
196
# File 'lib/active_record/connection_adapters/nuodb_adapter.rb', line 193

def initialize(connection, max)
  super
  @cache = Hash.new { |h, pid| h[pid] = {} }
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



191
192
193
# File 'lib/active_record/connection_adapters/nuodb_adapter.rb', line 191

def connection
  @connection
end

#maxObject (readonly)

Returns the value of attribute max.



191
192
193
# File 'lib/active_record/connection_adapters/nuodb_adapter.rb', line 191

def max
  @max
end

Instance Method Details

#[](key) ⇒ Object



206
207
208
# File 'lib/active_record/connection_adapters/nuodb_adapter.rb', line 206

def [](key)
  cache[key]
end

#[]=(sql, key) ⇒ Object



210
211
212
213
214
215
# File 'lib/active_record/connection_adapters/nuodb_adapter.rb', line 210

def []=(sql, key)
  while max <= cache.size
    dealloc cache.shift.last[:stmt]
  end
  cache[sql] = key
end

#clearObject



226
227
228
229
230
231
# File 'lib/active_record/connection_adapters/nuodb_adapter.rb', line 226

def clear
  cache.each_value do |hash|
    dealloc hash[:stmt]
  end
  cache.clear
end

#delete(key) ⇒ Object



221
222
223
224
# File 'lib/active_record/connection_adapters/nuodb_adapter.rb', line 221

def delete(key)
  dealloc cache[key][:stmt]
  cache.delete(key)
end

#each(&block) ⇒ Object



198
199
200
# File 'lib/active_record/connection_adapters/nuodb_adapter.rb', line 198

def each(&block)
  cache.each(&block)
end

#key?(key) ⇒ Boolean

Returns:

  • (Boolean)


202
203
204
# File 'lib/active_record/connection_adapters/nuodb_adapter.rb', line 202

def key?(key)
  cache.key?(key)
end

#lengthObject



217
218
219
# File 'lib/active_record/connection_adapters/nuodb_adapter.rb', line 217

def length
  cache.length
end