略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: TokyoTyrant::add

2024-12-23

TokyoTyrant::add

(PECL tokyo_tyrant >= 0.1.0)

TokyoTyrant::addAdds to a numeric key

说明

public TokyoTyrant::add ( string $key , number $increment [, int $type = 0 ] ) : number

Adds to an int or double value. This increments the value by the given amount and returns the new value. If the key does not exist a new key is created with initial value of the increment parameter.

参数

key

The string key

increment

The amount to increment

type

TokyoTyrant::RDBREC_INT or TokyoTyrant::RDBREC_DBL constant. If this parameter is omitted the type is guessed from the increment parameters type.

返回值

Returns the new value on success

范例

Example #1 TokyoTyrant::add() example

<?php
$tt 
= new TokyoTyrant("localhost"TokyoTyrant::RDBDEF_PORT);
/* Adds integer 3 to key and creates a new key */
$tt->add("test"3);

/* String value is converted to double */
echo $tt->add("test""3.5"TokyoTyrant::RDBREC_DBL);
?>

以上例程的输出类似于:

6.5

参见

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/tokyotyrant.add.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3