Performs vote processing.
@param bool $up whether this is upvote
@param int $count number of user cached votes
@return bool
@since 0.2
771865
public function podiumThumb($up = true, $count = 0)
    {
        $transaction = static::getDb()->beginTransaction();
        try {
            $loggedId = User::loggedId();
            if ($this->thumb) {
                if ($this->thumb->thumb == 1 && !$up) {
                    $this->thumb->thumb = -1;
                    if (!$this->thumb->save()) {
                        throw new Exception('Thumb saving error!');
                    }
                    if (!$this->updateCounters(['likes' => -1, 'dislikes' => 1])) {
                        throw new Exception('Thumb counters saving error!');
                    }
                } elseif ($this->thumb->thumb == -1 && $up) {
                    $this->thumb->thumb = 1;
                    if (!$this->thumb->save()) {
                        throw new Exception('Thumb saving error!');
                    }
                    if (!$this->updateCounters(['likes' => 1, 'dislikes' => -1])) {
                        throw new Exception('Thumb counters saving error!');
                    }
                }
            } else {
                $postThumb = new PostThumb();
                $postThumb->post_id = $this->id;
                $postThumb->user_id = $loggedId;
                $postThumb->thumb = $up ? 1 : -1;
                if (!$postThumb->save()) {
                    throw new Exception('PostThumb saving error!');
                }
                if ($postThumb->thumb) {
                    if (!$this->updateCounters(['likes' => 1])) {
                        throw new Exception('Thumb counters saving error!');
                    }
                } else {
                    if (!$this->updateCounters(['dislikes' => 1])) {
                        throw new Exception('Thumb counters saving error!');
                    }
                }
            }
            if ($count == 0) {
                Podium::getInstance()->podiumCache->set('user.votes.' . $loggedId, ['count' => 1, 'expire' => time() + 3600]);
            } else {
                Podium::getInstance()->podiumCache->setElement('user.votes.' . $loggedId, 'count', $count + 1);
            }
            $transaction->commit();
            return true;
        } catch (Exception $e) {
            $transaction->rollBack();
            Log::error($e->getMessage(), null, __METHOD__);
        }
        return false;
    }
779260
public function updateVote($vote)
    {

        $out = [
            "yes" => $vote->getYes(),
            "no" => $vote->getNo(),
        ];

        $this->updateValue($this->allPlayers, "VoteUpdater", Builder::getArray($out, true));
    }
1155178
public function incrementCount($tag, $count)
	{
		if($count <= 0) { return; }

		$tag->count = $tag->count + $count;
		$tag->save();
	}
772785
def up_vote(votable)
      is_votable?(votable)
      
      vote = get_vote(votable)
      
      if vote
        if vote.up_vote
          raise Exceptions::AlreadyVotedError.new(true)
        else
          vote.up_vote = true
          votable.down_votes -= 1
          self.down_votes -= 1 if has_attribute?(:down_votes)
        end
      else
        vote = Vote.create(:votable => votable, :voter => self, :up_vote => true)
      end
      
      votable.up_votes += 1
      self.up_votes += 1 if has_attribute?(:up_votes)  
      
      Vote.transaction do
        save
        votable.save
        vote.save
      end
      
      true
    end
379214
public function update( $count ) {
		update_post_meta(
			$this->post_id,
			'_inc2734_count_cache_' . $this->service_name,
			[
				'count'      => $count,
				'expiration' => time() + (int) apply_filters( 'inc2734_wp_share_buttons_count_cache_seconds', 60 * 5 ),
			]
		);
	}
296434
public function vote($vote = 0, $user_id = 0, $ip = null)
	{
		if (!$this->get('id'))
		{
			$this->addError(Lang::txt('No record found'));
			return false;
		}

		if (!$vote)
		{
			$this->addError(Lang::txt('No vote provided'));
			return false;
		}

		$ip = $ip ?: Request::ip();

		$al = $this->ballot($user_id, $ip);
		$al->set('item_type', 'comment');
		$al->set('item_id', $this->get('id'));
		$al->set('created_by', $user_id);
		if ($ip)
		{
			$al->set('ip', $ip);
		}

		$vote = $al->automaticVote(['vote' => $vote]);

		if ($this->get('created_by') == $user_id)
		{
			$this->addError(Lang::txt('Cannot vote for your own entry'));
			return false;
		}

		if ($vote != $al->get('vote', 0))
		{
			if ($vote > 0)
			{
				$this->set('positive', (int) $this->get('positive') + 1);
				if ($al->get('id'))
				{
					$this->set('negative', (int) $this->get('negative') - 1);
				}
			}
			else
			{
				if ($al->get('id'))
				{
					$this->set('positive', (int) $this->get('positive') - 1);
				}
				$this->set('negative', (int) $this->get('negative') + 1);
			}

			if (!$this->save())
			{
				return false;
			}

			$al->set('vote', $vote);

			if (!$al->save())
			{
				$this->addError($al->getError());
				return false;
			}
		}

		return true;
	}
1294188
public function seeAttachments($count)
    {
        $attachments = $this->fetchAttachmentsOfLastMessage();
        $this->assertEquals($count, count($attachments));
    }
227054
public function upVoteAction(Request $request)
    {
        $reference = $request->get('reference');
        $value = $request->get('value');
        $this->get('event_dispatcher')->dispatch(Events::VOTE_UP, new UpVoteEvent($request, $reference, $value));

        return;
    }
424147
private function getStatementContentAll($count = false)
    {
        $q = $this->connection->createQueryBuilder()
            ->select($count ? 'count(c.id)' : 'c.id')
            ->from('ezcontentobject', 'c')
            ->where('c.status = :status')
            ->setParameter('status', ContentInfo::STATUS_PUBLISHED, PDO::PARAM_INT);

        return $q->execute();
    }
343107
public function hit($count = 1)
	{
		$hitsLeft = $this->memcached->get($this->key);
		if ($this->memcached->getResultCode() == Memcached::RES_NOTFOUND)
		{
			// this is the first hit
			$hitsLeft = $this->hits;
			$this->memcached->set($this->key, $this->hits, time() + $this->seconds);
		}

		if ($hitsLeft < $count)
		{
			return false;
		}

		if ($this->memcached->decrement($this->key, $count) === false)
		{
			// it failed to decrement
			return false;
		}

		return true;
	}
723946
public function lremove($key, $count, $value)
    {
        try {
            return $this->redis->lremove($key, $count, $value);
        } catch (\RedisException $e) {
            die("Error!: " . $e->getMessage() . "<br/>");
        }
    }
1351434
protected function movePositionUpOrDown($up = true)
    {
        // The current position of the object
        $myPosition = $this->getPosition();

        // Find object to exchange position with
        $search = $this->createQuery();

        $this->addCriteriaToPositionQuery($search);

        // Up or down ?
        if ($up === true) {
            // Find the object immediately before me
            $search->filterByPosition(array('max' => $myPosition-1))->orderByPosition(Criteria::DESC);
        } else {
            // Find the object immediately after me
            $search->filterByPosition(array('min' => $myPosition+1))->orderByPosition(Criteria::ASC);
        }

        $result = $search->findOne();

        // If we found the proper object, exchange their positions
        if ($result) {
            $cnx = Propel::getWriteConnection($this->getDatabaseName());

            $cnx->beginTransaction();

            try {
                $this
                    ->setPosition($result->getPosition())
                    ->save($cnx)
                ;

                // For BC
                if (method_exists($result, 'setDispatcher') && method_exists($this, 'getDispatcher')) {
                    $result->setDispatcher($this->getDispatcher());
                }

                $result->setPosition($myPosition)->save($cnx);

                $cnx->commit();
            } catch (\Exception $e) {
                $cnx->rollback();
            }
        }
    }
199922
public function resetCache($count = 100) {
    $timer = 'reset_cache';
    Timer::start($timer);

    $result = $this->queryFactory->get(self::ENTITY_TYPE)->execute();
    if (empty($result)) {
      $this->logger->info('No cache was found. Nothing to clear.');
      Timer::stop($timer);
      return;
    }

    $this->removeByChunk($result, $count);

    $msg = 'All caches were cleared. [items removed: %items, elapsed time: %time sec.]';
    $this->logger->info(
      $msg,
      [
        '%items' => count($result),
        '%time' => round(Timer::read($timer) / 1000, 1)
      ]
    );

    Timer::stop($timer);
  }
984006
public function vote($commentId, $vote)
    {
        $this->validateVoteArgument($vote, ['up', 'down']);

        return $this->post('comment/' . $commentId . '/vote/' . $vote);
    }
917411
public function stream_read($count)
    {
        $ret = substr($this->_data, $this->_pos, $count);
        $this->_pos += strlen($ret);
        return $ret;
    }
281833
protected function getBaseSelect($count = FALSE)
    {
        $select = 'SELECT ';
        if ($count) {
            $select .= 'SQL_CALC_FOUND_ROWS ';
        }
        $select .= $this->getBaseSelector() . ' FROM ' . $this->getBaseTable();
        return $select;
    }
531474
public function count($count = null)
    {
        if ($count === null) {
            return isset($this->options['count']) ? $this->options['count'] : 0;
        } else {
            $this->options['count'] = $count;
            return $this;
        }
    }