Class: ActiveRecord::ConnectionAdapters::NuoDBAdapter::StatementPool
- Inherits:
-
ConnectionAdapters::StatementPool
- Object
- ConnectionAdapters::StatementPool
- ActiveRecord::ConnectionAdapters::NuoDBAdapter::StatementPool
- Defined in:
- lib/active_record/connection_adapters/nuodb_adapter.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#max ⇒ Object
readonly
Returns the value of attribute max.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(sql, key) ⇒ Object
- #clear ⇒ Object
- #delete(key) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(connection, max) ⇒ StatementPool
constructor
A new instance of StatementPool.
- #key?(key) ⇒ Boolean
- #length ⇒ Object
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
#connection ⇒ Object (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 |
#max ⇒ Object (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 |
#clear ⇒ Object
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
202 203 204 |
# File 'lib/active_record/connection_adapters/nuodb_adapter.rb', line 202 def key?(key) cache.key?(key) end |
#length ⇒ Object
217 218 219 |
# File 'lib/active_record/connection_adapters/nuodb_adapter.rb', line 217 def length cache.length end |