Count the results in a group in the cache backend
344779
def count_group_cached(group_id, failures=False, broker=None):
    
    if not broker:
        broker = get_broker()
    group_list = broker.cache.get('{}:{}:keys'.format(broker.list_key, group_id))
    if group_list:
        if not failures:
            return len(group_list)
        failure_count = 0
        for task_key in group_list:
            task = SignedPackage.loads(broker.cache.get(task_key))
            if not task['success']:
                failure_count += 1
        return failure_count
200763
def count(self, objectType, *args, **coolArgs) :
		""""""
		return self._makeLoadQuery(objectType, *args, **coolArgs).count()
391272
def get_results(group_name)
      queue = ChimpQueue.instance
      Log.debug("getting results for group #{group_name}")
      results = queue.group[@group].results()
      failed_workers = []
      results_display = []

      results.each do |result|
        next if result == nil

        if result[:status] == :error
          name = result[:host] || "unknown"
          message = result[:error].to_s || "unknown"
          message.sub!("\n", "")
          failed_workers << result[:worker]
          results_display << "#{name[0..40]}  >> #{message}"
        end
      end

      return [failed_workers, results_display]
    end
1166213
function recursive_groups($group, $cache_only = FALSE) {
        $this->_debug_message = "";
        $this->_warning_message = "";
        if ($group==NULL){ return (false); }

        $ret_groups=array();
        $ret_data = FALSE;

/*
    echo "DEBUG GROUP is group $group in cache ?\n";
    print_r($this->_cache_recursive_groups);
*/

        clearstatcache();
        
		if ($this->_cache_support) {
            if ("" != $this->get_cache_folder()) {
                if (file_exists($this->get_cache_folder()."ldap_rgroup_".md5($group).".cache")) {
                    if ((filemtime($this->get_cache_folder()."ldap_rgroup_".md5($group).".cache") + $this->get_cache_timeout()) > time()) {
                        if ($cache_handle = fopen($this->get_cache_folder()."ldap_rgroup_".md5($group).".cache", "rb")) {
                            $ret_groups = unserialize(fgets($cache_handle));
                            $ret_data = TRUE;
                            fclose($cache_handle);
                            @touch($this->get_cache_folder()."ldap_rgroup_".md5($group).".cache");
                        }
                    }
                }
            } elseif (isset($this->_cache_recursive_groups[$group])) {
                $ret_groups = $this->_cache_recursive_groups[$group];
                $ret_data = TRUE;
            }
        }

    	if (!$ret_data) {
            if (!$cache_only) {
    			$groups=$this->group_info($group,array($this->_group_attribute));
    			
    			// Additional test by SysCo/al
    			if (isset($groups[0][$this->_group_attribute]))
    			{
    				$groups=$groups[0][$this->_group_attribute];

    				if ($groups){
    					$group_names=$this->nice_names($groups);

    					$ret_groups=array_merge($ret_groups,$group_names); //final groups to return
    					
    					foreach ($group_names as $id => $group_name){
    						$child_groups=$this->recursive_groups($group_name);
    						$ret_groups=array_merge($ret_groups,$child_groups);
    					}
    				}
    			}
    			if ($this->_cache_support) {
                    if ("" != $this->get_cache_folder()) {
                        if (file_exists($this->get_cache_folder())) {
                            if ($cache_handle = fopen($this->get_cache_folder()."ldap_rgroup_".md5($group).".cache", "wb")) {
                                fwrite($cache_handle, serialize($ret_groups));
                                fclose($cache_handle);
                                @chmod($this->get_cache_folder()."ldap_rgroup_".md5($group).".cache", octdec($this->_linux_file_mode));
                            }
                        }
                    } else {
        				$this->_cache_recursive_groups[$group] = $ret_groups;
                    }
    			}
            } else {
                $this->_debug_message = "The requested group $group is not in cache.";
            }
        }
        return ($ret_groups);
    }
1283486
def group_read(self, addr, use_cache=True, timeout=1):
        """"""
        if use_cache:
            res = self.value_cache.get(addr)
            if res:
                logging.debug(
                    "Got value of group address %s from cache: %s", addr, res)
                return res

        cemi = CEMIMessage()
        cemi.init_group_read(addr)

        with self._lock:
            # There might be old messages in the result quue, remove them
            self.result_queue.queue.clear()
            self.send_tunnelling_request(cemi)
            # Wait for the result
            try:
                res = self.result_queue.get(block=True, timeout=timeout)
            except queue.Empty:
                return None

            self.result_queue.task_done()
            return res
1115791
def cache_results(&block)
        if template_cache_configured? && Rabl.configuration.cache_all_output && @_object.respond_to?(:cache_key)
          cache_key = [@_object, @options[:root_name], @options[:format]]

          fetch_result_from_cache(cache_key, &block)
        else # skip cache
          yield
        end
      end
618589
def count(cls, filter=None, **kwargs):
        """"""
        from mongoframes.queries import Condition, Group, to_refs

        if isinstance(filter, (Condition, Group)):
            filter = filter.to_dict()

        return cls.get_collection().count(to_refs(filter), **kwargs)
1374860
def local_count(duration, type)
      aggr = {}
      Octo::Enterprise.each do |enterprise|
        args = {
            enterprise_id: enterprise.id,
            ts: duration,
            type: type
        }
        aggr[enterprise.id.to_s] = {} unless aggr.has_key?(enterprise.id.to_s)
        results = where(args)
        results_group = results.group_by { |x| x.uid }
        results_group.each do |uid, counters|
          _sum = counters.inject(0) do |sum, counter|
            sum + counter.count
          end
          aggr[enterprise.id.to_s][uid] = _sum
        end
      end
      aggr
    end
58379
def result(self, wait=0):
        
        if self.started:
            return result_group(self.group, wait=wait, count=self.length(), cached=self.cached)
313081
def groups_count(self):
        
        if self._keyboard_description.contents.ctrls is not None:
            return self._keyboard_description.contents.ctrls.contents.num_groups
        else:
            groups_source = self._groups_source

            groups_count = 0
            while (groups_count < XkbNumKbdGroups and
                   groups_source[groups_count] != None_):
                groups_count += 1

            return groups_count
927844
function count(query, callback) {
    self.emit('count', query)
    findByQuery(query, options, function (error, objects) {
      self.emit('received', objects.length)
      callback(undefined, objects.length)
    })
  }
905445
function(_cache,_result){
            var _data = {
                data:_result
            };
            // parse ext headers
            var _keys = _cache.result.headers;
            if (!!_keys){
                _data.headers = _cache.req._$header(_keys);
            }
            // TODO parse other ext data
            return _data;
        }
281208
def _find_usage_parameter_groups(self):
        """"""
        num_groups = 0

        paginator = self.conn.get_paginator('describe_cache_parameter_groups')
        for page in paginator.paginate():
            for group in page['CacheParameterGroups']:
                num_groups += 1
        self.limits['Parameter Groups']._add_current_usage(
            num_groups,
            aws_type='AWS::ElastiCache::ParameterGroup'
        )
712150
def get_group(name):
    
    group = cache.get('bits.general.group_%s' % name)
    if not group:
        group = Group.objects.get(name=name)
        cache.set('bits.general.group_%s' % name, group, 365 * 24 * 60 * 60)
    return group
978155
function preCacheQueries(queries) {
  var groupBy = {};
  _.each(queries, function (query) {
    if (!query.queryKey) {
      return;
    }
    var hasAllValues = _.reduce(_.values(query.queryParams), function (acc, val) {
      return acc && (val !== null);
    }, true);
    if (hasAllValues) {
      var cacheKey = _executionCache.getKey(query);
      groupBy[cacheKey] = groupBy[cacheKey] || [];
      groupBy[cacheKey].push(query);
    }
  });

  _.each(groupBy, function (groupedQueries, key) {
    var aggregateShape = _.reduce(_.map(groupedQueries, 'shape'), _.assign, {});
    var query = _.cloneDeep(groupedQueries[0]);
    query.shape = aggregateShape;
    _executionCache.execute(query);
  });
}
1040839
def cache_results(&block)
        return yield unless template_cache_configured? && defined?(@_cache_key)

        if cache_read_on_render?
          fetch_result_from_cache(cache_key, @_cache_options, &block)
        else
          write_result_to_cache(cache_key, @_cache_options, &block)
        end
      end
1188791
function count(req, res,next) {
  db.tags.count(function(err, count) {
    if(err) { return next(err); }
    res.json({count: count});
  });
}