Fetch a single interval from redis.
183251
def _get(self, name, interval, config, timestamp, **kws):
    '''
    
    '''
    i_bucket, r_bucket, i_key, r_key = self._calc_keys(config, name, timestamp)
    fetch = kws.get('fetch') or self._type_get
    process_row = kws.get('process_row') or self._process_row

    rval = OrderedDict()
    if config['coarse']:
      data = process_row( fetch(self._client, i_key) )
      rval[ config['i_calc'].from_bucket(i_bucket) ] = data
    else:
      # First fetch all of the resolution buckets for this set.
      resolution_buckets = sorted(map(int,self._client.smembers(i_key)))

      # Create a pipe and go fetch all the data for each.
      # TODO: turn off transactions here?
      pipe = self._client.pipeline(transaction=False)
      for bucket in resolution_buckets:
        r_key = '%s:%s'%(i_key, bucket)   # TODO: make this the "resolution_bucket" closure?
        fetch(pipe, r_key)
      res = pipe.execute()

      for idx,data in enumerate(res):
        data = process_row(data)
        rval[ config['r_calc'].from_bucket(resolution_buckets[idx]) ] = data

    return rval
584349
def _get (self, timeout):
        """"""
        if timeout is None:
            while self._empty():
                self.not_empty.wait()
        else:
            if timeout < 0:
                raise ValueError("'timeout' must be a positive number")
            endtime = _time() + timeout
            while self._empty():
                remaining = endtime - _time()
                if remaining <= 0.0:
                    raise Empty()
                self.not_empty.wait(remaining)
        self.in_progress += 1
        return self.queue.popleft()
1174059
def used
      return 0 if max.zero?

      expiry = redis.pttl(key)
      case expiry
      when -1  # key exists but has no associated expire
        raise Errors::InvalidKeyError, "Redis key #{key} has no expire time set"
      when -2  # key does not exist
        return 0
      end

      (max * expiry / (period * 1000.0)).ceil
    end
157503
function interval(start, end) {
  if (arguments.length === 1 && typeof start === 'string') {
    return start
  }
  else if (arguments.length === 2) {
    var interval = utils.args(arguments, 0)

    return interval.map(function(original) {
      var arg = utils.date(original)

      if (!arg) {
        throw new FieldError('Bad date specified: ' + original)
      }

      return JSON.stringify(arg).replace(/"/g, '')
    }).join('/')
  }
  else {
    throw new FieldError('Bad arguments')
  }
}
29037
def redis(self):
        """"""
        if self._redis is None:
            self._redis = redis.StrictRedis(host=self.args.redis_host, port=self.args.redis_port)
        return self._redis
573413
def from_interval(self, startnote, shorthand, up=True):
        """"""
        return self.from_interval_shorthand(startnote, shorthand, up)
45237
def fetch_31(self):
        """"""
        today = datetime.datetime.today()
        before = today - datetime.timedelta(days=60)
        self.fetch_from(before.year, before.month)
        self.data = self.data[-31:]
        return self.data
900705
def get_results(self, stream, time_interval):
        
        return [StreamInstance(t, self.data[stream.stream_id][t])
                for t in sorted(self.data[stream.stream_id]) if t in time_interval]
244379
def pttl(self, key):
        
        """
        Returns time to live in milliseconds if output_ms is True, else returns seconds.
        """
        key = self._encode(key)
        if key not in self.redis:
            # as of redis 2.8, -2 is returned if the key does not exist
            return long(-2) if self.strict else None
        if key not in self.timeouts:
            # as of redis 2.8, -1 is returned if the key is persistent
            # redis-py returns None; command docs say -1
            return long(-1) if self.strict else None

        time_to_live = get_total_milliseconds(self.timeouts[key] - self.clock.now())
        return long(max(-1, time_to_live))
1053925
function getNamedInterval($id = null)
        {
            # if $id name is null
            if ($id === null) {
                # return the latest interval
                foreach($this->intervals as $id =>$val) ;
                $ret = "$id = $val";
            # else if there is a $id name
            } elseif (Arrays::exists($id, $this->intervals)) {
                # return the named interval
                $ret = "$id = {$this->intervals[$id]}";
            }

            # else return 'no value'
            else $ret = "$id = no value";
            return $ret;
        }
707425
def get_redis_info():
    """"""
    from kombu.utils.url import _parse_url as parse_redis_url
    from redis import (
        StrictRedis,
        ConnectionError as RedisConnectionError,
        ResponseError as RedisResponseError,
    )
    for conf_name in ('REDIS_URL', 'BROKER_URL', 'CELERY_BROKER_URL'):
        if hasattr(settings, conf_name):
            url = getattr(settings, conf_name)
            if url.startswith('redis://'):
                break
    else:
        log.error("No redis connection info found in settings.")
        return {"status": NO_CONFIG}
    _, host, port, _, password, database, _ = parse_redis_url(url)

    start = datetime.now()
    try:
        rdb = StrictRedis(
            host=host, port=port, db=database,
            password=password, socket_timeout=TIMEOUT_SECONDS,
        )
        info = rdb.info()
    except (RedisConnectionError, TypeError) as ex:
        log.error("Error making Redis connection: %s", ex.args)
        return {"status": DOWN}
    except RedisResponseError as ex:
        log.error("Bad Redis response: %s", ex.args)
        return {"status": DOWN, "message": "auth error"}
    micro = (datetime.now() - start).microseconds
    del rdb  # the redis package does not support Redis's QUIT.
    ret = {
        "status": UP, "response_microseconds": micro,
    }
    fields = ("uptime_in_seconds", "used_memory", "used_memory_peak")
    ret.update({x: info[x] for x in fields})
    return ret
850550
def _interval(dates):
        """"""
        interval = (dates[1] - dates[0]).days
        last = dates[0]
        for dat in dates[1:]:
            if (dat - last).days != interval:
                return 0
            last = dat
        return interval
830063
def iteritems(self, pipe=None):
        """"""
        pipe = self.redis if pipe is None else pipe
        for k, v in self._data(pipe).items():
            yield k, self.cache.get(k, v)
435003
def _interval_split(interval, only=None, context=None, event_re=re.compile("[A-Z][0-9]+")):
    
    def split_event(event):
        "Helper to parse events."
        kind, val = event[:1], event[1:]
        try:
            return kind, float(val)
        except (TypeError, ValueError):
            return None, 0

    if hasattr(interval, "fetch"):
        interval = interval.fetch("custom_activations")
    ##import sys; print >>sys.stderr, "!!!!!isplit", interval, event_re.findall(interval)

    return list(reversed([split_event(i) for i in event_re.findall(interval) if not only or i.startswith(only)]))
1102995
def fetch(self):
        
        LOGGER.debug('Fetching session data: %s', self.id)
        result = yield gen.Task(RedisSession._redis_client.get, self._key)
        if result:
            self.loads(result)
            raise gen.Return(True)
        else:
            raise gen.Return(False)
1149965
def feed_interval_get(feed_id, parameters):
	''
	val = cache.get(getkey( T_INTERVAL,
		key=feed_interval_key(feed_id, parameters) ))
	return val if isinstance(val, tuple) else (val, None)
1281336
def expireat(self, key, when):
        """"""
        expire_time = datetime.fromtimestamp(when)
        key = self._encode(key)
        if key in self.redis:
            self.timeouts[key] = expire_time
            return True
        return False