Source: show | on GitHub
# File activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 256 256: def initialize(connection, max) 257: super 258: @counter = 0 259: @cache = Hash.new { |h,pid| h[pid] = {} } 260: end
# File activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 264 264: def [](key); cache[key]; end
# File activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 271 271: def []=(sql, key) 272: while @max <= cache.size 273: dealloc(cache.shift.last) 274: end 275: @counter += 1 276: cache[sql] = key 277: end
# File activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 279 279: def clear 280: cache.each_value do |stmt_key| 281: dealloc stmt_key 282: end 283: cache.clear 284: end
# File activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 286 286: def delete(sql_key) 287: dealloc cache[sql_key] 288: cache.delete sql_key 289: end
# File activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 262 262: def each(&block); cache.each(&block); end
# File activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 263 263: def key?(key); cache.key?(key); end
# File activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 265 265: def length; cache.length; end
# File activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 267 267: def next_key 268: "a#{@counter + 1}" 269: end