Sends a count to StatsD

@param string $key
@param int $value
@param int $sampleRate (optional) the default is 1
509051
public function count($key, $value, $sampleRate = 1)
    {
        $this->updateStats($key, (int)$value, $sampleRate, 'c');
    }
798955
def sample_rate(self, value):
        
        if value == self._defaults['sampleRate'] and 'sampleRate' in self._values:
            del self._values['sampleRate']
        else:
            self._values['sampleRate'] = value
1118454
public function counter($metric, $count = 1, array $tags = array(), $sampleRate = AbstractMetric::DEFAULT_SAMPLE_RATE)
    {
        try {
            $this->sendMetric($this->metricFactory->counter($metric, $count, $tags, $sampleRate));
        } catch (\Exception $exception) {
            $this->logException($exception);
        }

        return $this;
    }
260848
public function rpush($key, $value) {

        $list = $this->get($key, array());

        $list[] = $value;

        $this->set($key, $list);

        return count($list);
    }
211011
public function offsetSet($key, $value)
    {
        if ($key === null) {
            $intKeys = array_filter($this->keys, 'is_int');
            $this->keys[] = $i = empty($intKeys) ? 0 : max(max($intKeys) + 1, 0);
            $this->values[] = $value;
            $this->keysIndices[$i] = count($this->values) - 1;
        } elseif (($index = $this->keysIndices[self::keyString($key)] ?? null) === null) {
            $this->keys[] = $key;
            $this->values[] = $value;
            $this->keysIndices[self::keyString($key)] = count($this->values) - 1;
        } else {
            $this->values[$index] = $value;
        }
    }
402341
public function putVars($key, $value = null)
    {
        if (is_array($key)) {
            $variables = $key;
        } elseif (!is_null($value)) {
            $variables = [$key => $value];
        } else {
            throw new Exception('Try Assets::putVars(["foo" => "bar"]');
        }

        // First, we have to translate the variables
        // to something JS-friendly.
        $this->buildJavaScriptSyntax($variables);

        return $this;
    }
165065
public function send(array $data, $sampleRate = 1)
    {
        if (!$this->enable) {
            return;
        }

        // sampling
        $sampledData = array();
        if ($sampleRate < 1) {
            foreach ($data as $stat => $value) {
                if ((mt_rand() / mt_getrandmax()) <= $sampleRate) {
                    $sampledData[$stat] = "$value|@$sampleRate";
                }
            }
        } else {
            $sampledData = $data;
        }
        if (empty($sampledData)) {
            return;
        }

        $fp = fsockopen('udp://' . $this->host, $this->port, $errno, $errstr);
        if (!$fp) {
            return;
        }
        foreach ($sampledData as $stat => $value) {
            fwrite($fp, $stat . ':' . $value);
        }
        fclose($fp);
    }
616549
protected function setJavascriptData($key, $value = null)
    {
        if (is_array($key)) {
            JavaScriptFacade::put($key);
        } else {
            JavaScriptFacade::put([$key => $value]);
        }
    }
1008272
public void addSample(final T item, final long hash, final int value)
    {
        if (enabled)
        {
            final Object lock = this;
            samplerExecutor.execute(new Runnable()
            {
                public void run()
                {
                    // samplerExecutor is single threaded but still need
                    // synchronization against jmx calls to finishSampling
                    synchronized (lock)
                    {
                        if (enabled)
                        {
                            try
                            {
                                summary.offer(item, value);
                                hll.offerHashed(hash);
                            } catch (Exception e)
                            {
                                logger.debug("Failure to offer sample", e);
                            }
                        }
                    }
                }
            });
        }
    }
1213661
public function write($key, $value, $expire = null) 
    {
        if (!$this->enabled) {
            return ;
        }

        if ($expire === null) {
            $expire = $this->expire;
        }
        
        $value = serialize($value);
        $cachePath = $this->getCachePath($key);
        
        $this->stats['execTimes'] ++;
        $this->stats['writeTimes'] ++;
        $this->stats['writeSize'] += strlen($value)/1024;
            
        try {            
            $this->waitUnlock($key);
            $this->lock($key);
            $set = $this->obj->set($cachePath, $value);
            $this->obj->setTimeout($cachePath, $expire);
            $this->unlock($key);
        } catch (\wf\cache\Exception $e) {
            $this->unlock($key);
            throw $e;
        }
    }
1237917
public function put($key, $value, $minutes)
    {
        if ($minutes instanceof \Datetime) {
            $seconds = $minutes->getTimestamp() - time();
        } else {
            $seconds = $minutes * 60;
        }
        $this->redis->setex($this->decorateKey($key), $seconds, $value);
    }
191998
public function write($key, $value, $expire = null) 
    {
        if (!$this->enabled) {
            return ;
        }

        if ($expire === null) {
            $expire = $this->expire;
        }
        
        $data = [
            'time'   => time(),
            'expire' => time() + $expire,
            'value'  => $value,
        ];
    
        $this->stats['execTimes'] ++;
        $this->stats['writeTimes'] ++;            
        $this->stats['writeSize'] += strlen(var_export($value, true))/1024;
        $this->temp[$key] = $data;
        
        try {
            $this->waitUnlock($key);
            $this->lock($key);
            $this->store($key, $data);
            $this->unlock($key);
        } catch (\wf\cache\Exception $e) {
            $this->unlock($key);
            throw $e;
        }
    }
52692
private function insertRecord(string $id, string $key, string $value) : void
    {
        $query = sprintf(
            'INSERT INTO %s (%s, %s, %s, %s) VALUES(?, ?, ?, ?)',
            $this->options['table-name'],
            $this->options['id-column'],
            $this->options['key-column'],
            $this->options['value-column'],
            $this->options['last-access-column']
        );

        $statement = $this->pdo->prepare($query);
        $statement->execute([$id, $key, $value, time()]);
    }
768360
public function lpush($collection, $key, $value) {

        $list = $this->getKey($collection, $key, []);

        array_unshift($list, $value);

        $this->setKey($collection, $key, $list);

        return count($list);
    }
771687
public static function set($key, $value) {

		if(false === is_string($key)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($key)), E_USER_ERROR);
		}

		static :: $data[$key] = $value;
	}
109022
public function lPush($key, $value) {
        try {
            $this->_redis->lPush($key, $value);
        } catch (Predis\Response\ServerException $e) {
            throw new CM_Exception_Invalid('Cannot push key to list.', null, ['key' => $key]);
        }
    }
968032
public function setSamplingRate($samplingRate)
    {
        if ($samplingRate <= 0.0 || 1.0 < $samplingRate) {
            throw new \LogicException('Sampling rate shall be within ]0, 1]');
        }
        $this->samplingRate = $samplingRate;
        $this->samplingFunction = function($min, $max){
            return rand($min, $max);
        };
    }