Class: Queris::QueryProfilerLite

Inherits:
QueryProfilerBase show all
Defined in:
lib/queris/profiler.rb

Overview

does not store properties in a hash, and writes only to indices. useful for Redises with crappy or no HINCRBYFLOAT implementations (<=2.6) as a result, loading stats is suboptimal, but still O(1)

Constant Summary

Constants included from Queris

VERSION

Instance Attribute Summary

Attributes inherited from Profiler

#last_sample

Attributes inherited from Model

#id, #query_score

Instance Method Summary collapse

Methods inherited from QueryProfilerBase

find, query_profile_id, #set_id

Methods inherited from Profiler

#attribute_diff, average, default_statistic, #finish, #increment, #initialize, named_stat, #record, sample, #sample_unit, #samples, samples, #save, #start, stats, unit

Methods inherited from Model

#as_json, attr_val_block, attribute, #attribute_diff, attributes, attrs, #changed, #changed?, #delete, #deleted?, expire, find, find_all, get, #hash_key, #import, #increment, #initialize, keyf, #load_missing, #loaded?, #noload, #noload?, prefix, redis, #redis, #redis=, restore, #save, #set_id, #to_json, #while_loading

Methods included from QuerisModelMixin

included

Methods included from ObjectMixin

#get_cached_attribute, included

Methods included from Queris

add_redis, all_redises, build_missing_indices!, clear!, clear_cache!, clear_queries!, debug?, digest, disconnect, duplicate_redis_client, from_redis_float, import_lua_script, included, info, load_lua_script, #log_stats_per_request!, #log_stats_per_request?, model, rebuild!, reconnect, redis, redis_prefix, redis_role, redises, register_model, run_script, script, script_hash, #stats, to_redis_float, #track_stats!, #track_stats?

Constructor Details

This class inherits a constructor from Queris::Profiler

Instance Method Details

#load(query = nil) ⇒ Object

load from sorted sets through a pipeline



258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
# File 'lib/queris/profiler.rb', line 258

def load(query=nil) #load from sorted sets through a pipeline
  stats = self.class.stats
  #The following code SHOULD, in some future, load attributes
  # through self.class.stats. For now loading all zsets will do.
  res = (redis || query.model.redis).multi do |r|
    stats.each do |_, statistic|
      r.zscore index.sorted_set_key, id
    end
  end
  indices.each do |index|
    unless (val = res.shift).nil?
      self.import index.name => val.to_f
    end
  end
  self
end