Method saves last tick and current balance into cache

@param integer $lastTick
@param float $balance
765227
private function saveState($lastTick, $balance)
    {
        $this->lastTick->set($lastTick);
        $this->balance->set($balance);
        $this->cache->saveDeferred($this->lastTick);
        $this->cache->saveDeferred($this->balance);
        $this->cache->commit();
    }
1009128
public void last(String name, float value) {
		Counter counter = get(name, CounterType.LastValue);
		counter.setLast(value);
		update();
	}
673974
protected function waitNextMilli($lastTimestamp):int
    {
        $timestamp = $this->milliTime();
        while ($timestamp <= $lastTimestamp) {
            $timestamp = $this->milliTime();
        }
        return $timestamp;
    }
583863
protected function cacheCountBetween($count, Carbon $from, Carbon $until, $locale, $cacheKey)
    {
        // Cache only if cacheKey is present
        if ($cacheKey && ($until->timestamp < Carbon::now()->timestamp))
        {
            $key = $this->makeBetweenCacheKey($from, $until, $locale, $cacheKey);

            $this->cache->put($key, $count, 525600);
        }
    }
815726
@Override
  protected void clearCache() {
    if (lastX != null) lastX[0] = Double.NaN;
    if (lastXBatch != null) lastXBatch[0] = Double.NaN;
    if (lastVBatch != null) lastVBatch[0] = Double.NaN;
  }
972433
public function AddLast( $pathStep )
	{
		/**
		 * @var PathStep $last
		 */
		$last = $this;
		while ( ! is_null( $last->next ) )
			$last = $last->next;
		$last->next = $pathStep;
	}
315832
def __updatePreviousState(self, tick):
        '''  '''
        self.__previousTick=tick
        self.__previousSmaShort=self.__smaShort.getLastValue()
        self.__previousSmaMid=self.__smaMid.getLastValue()
        self.__previousSmaLong=self.__smaLong.getLastValue()
        self.__previousSmaVolumeShort=self.__smaVolumeShort.getLastValue()
        self.__previousSmaVolumeMid=self.__smaVolumeMid.getLastValue()
        self.__previousMovingLowShort=self.__movingLowShort.getLastValue()
        self.__previousMovingLowWeek=self.__movingLowWeek.getLastValue()
726804
public function hold($amount, $desc='Hold', $cat, $ref)
	{
		$amount = $this->_amountCheck($amount);

		if ($this->getError())
		{
			echo $this->getError();
			return;
		}

		// Current order processing workflow (which requires manual order fulfillment on the backend) prevents race
		// condition with the check and update below from corrupting user point balance, but if
		// but if workflow is ever changed, a table/row level lock would need to be added to this function
		// and error code added to deal with multiple orders with insufficient balances.
		//
		// See https://hubzero.org/support/ticket/234 for details

		if ($this->_creditCheck($amount))
		{
			$this->credit += $amount;

			if (!$this->_save('hold', $amount, $desc, $cat, $ref))
			{
				echo $this->getError();
			}
		}
		else
		{
			echo $this->getError();
		}
	}
1009540
protected function addLastLink(&$lastLink)
    {
        $lastLink = $this->getLink($this->calculatePageRowNumberForLastLink(), $this->getStyleClassAttributes('last'), $this->lastName);
    }
490160
static void writeLastTxidToZookeeper(long lastTxid, long totalBlocks,
      long totalInodes, long ssid, Configuration startupConf,
      Configuration confg) throws IOException {
    AvatarZooKeeperClient zk = null;
    LOG.info("Writing lastTxId: " + lastTxid + ", total blocks: " + totalBlocks
        + ", total inodes: " + totalInodes);
    if (lastTxid < 0) {
      LOG.warn("Invalid last transaction id : " + lastTxid
          + " skipping write to zookeeper.");
      return;
    }
    ZookeeperTxId zkTxid = new ZookeeperTxId(ssid, lastTxid, totalBlocks,
        totalInodes);
    int maxTries = startupConf.getInt("dfs.avatarnode.zk.retries", 3);
    for (int i = 0; i < maxTries; i++) {
      try {
        zk = new AvatarZooKeeperClient(confg, null, false);
        zk.registerLastTxId(startupConf.get(NameNode.DFS_NAMENODE_RPC_ADDRESS_KEY), zkTxid);
        return;
      } catch (Exception e) {
        LOG.error("Got Exception when syncing last txid to zk. Will retry...",
            e);
      } finally {
        shutdownZkClient(zk);
      }
    }
    throw new IOException("Cannot connect to zk");
  }
1043062
private function appendLastModified($timestamp, $maxAge)
    {
        $headers = array(
            'Cache-Control' => sprintf('public, max-age=%s', $maxAge),
            'Last-Modified' => gmdate('D, j M Y H:i:s', $timestamp).' GMT'
        );

        $this->headerBag->setStatusCode(200)
                        ->appendPairs($headers);
    }
1051187
function (tickInterval, min, max) {
		var pos,
			lastPos,
			roundedMin = correctFloat(mathFloor(min / tickInterval) * tickInterval),
			roundedMax = correctFloat(mathCeil(max / tickInterval) * tickInterval),
			tickPositions = [];

		// Populate the intermediate values
		pos = roundedMin;
		while (pos <= roundedMax) {

			// Place the tick on the rounded value
			tickPositions.push(pos);

			// Always add the raw tickInterval, not the corrected one.
			pos = correctFloat(pos + tickInterval);

			// If the interval is not big enough in the current min - max range to actually increase
			// the loop variable, we need to break out to prevent endless loop. Issue #619
			if (pos === lastPos) {
				break;
			}

			// Record the last value
			lastPos = pos;
		}
		return tickPositions;
	}
137264
def last(self, name, value):
        
        counter = self.get(name, CounterType.LastValue)
        counter.last = value
        self._update()
1140584
public function takeLast(int $count)
    {
        return $this->wrap(function (Iterator $data) use ($count) {
            // From the end of the collection
            $limit = max(0, $count);
            $chunk = [];

            foreach ($data as $key => $datum) {
                $chunk[] = [$key, $datum];
                if (count($chunk) > $limit) {
                    array_shift($chunk);
                }
            }

            foreach ($chunk as $item) {
                [$key, $datum] = $item;
                yield $key => $datum;
            }
        });
    }
1108360
public function balance () {
			if (!isset($this->cache['balance'])) {
				$tmp = $this->apiCall('get_balance');
				if (!$tmp['data']) return false;

				$this->cache['balance'] = $tmp['data']['value'];
			}

			return (float)$this->cache['balance'];
		}
550827
def tick(self):
        """"""
        now = datetime.datetime.now()
        self.add(now)

        # Create a list of timestamps, one for each period and
        # representing the beginning of that period (i.e. since now.)
        tstamps = [now - datetime.timedelta(seconds=xx)
                   for xx in self._periods]

        # Trim off any tick values older than the earliest timestamp.
        self.removeLT(min(tstamps))

        # Create a list of counts, one for each period and
        # representing the number of ticks in that period.
        counts = [self.getCountGT(xx) for xx in tstamps]

        # Compute a list of rates for the periods.
        rates = [float(xx)/yy for xx, yy in zip(counts, self._periods)]

        # Return the rates as a tuple.
        return tuple(rates)
549552
private function validateCustomerBalance($balance, $amount, $useDelta = false)
    {
        if ($useDelta) {
            $result = (($balance + self::CONVERSION_DELTA) >= $amount);
        } else {
            $result = ($balance >= $amount);
        }
        return $result;
    }