swoole_table->incr [编辑本页]

原子自增操作。

function swoole_table->incr(string $key, string $column, mixed $incrby = 1);
  • $key 指定数据的key,如果$key对应的行不存在,默认列的值为0
  • $column 指定列名,仅支持浮点型和整型字段
  • $incrby 增量,默认为1。如果列为整形,$incrby必须为int型,如果列为浮点型,$incrby必须为float类型
  • 失败返回false,成功返回最终的结果数值

swoole_table->incr在1.7.15以上版本可用


  • 无枪草民

    decr:8

    1503125408183; 1503125414182 -> 26 incr:9 incr:12 incr:11 incr:10 incr:13 incr:14 incr:15 incr:16 incr:18 incr:19 incr:17 incr:20 incr:21 incr:22 incr:23 incr:24 incr:25 incr:26 incr:27 incr:28 incr:32 incr:30 incr:33 incr:29 incr:31 incr:34 Expception:{"workerId":"141","workerName":"\u62c9\u53d6\u9489\u9489\u6570\u636e","taskName":"","type":"timer"}任务已暂停/opt/erp/application/common/service/TaskExecuter.php123 decr:33

  • 无枪草民

    table-incr在 task不安全的吗? incr:9 incr:12 了。

  • 无枪草民

    ➜ erp git:(8f46b48) ✗ php --ri swoole

    swoole

    swoole support => enabled Version => 1.9.14 Author => tianfeng.han[email: mikan.tenny@gmail.com] epoll => enabled eventfd => enabled timerfd => enabled signalfd => enabled cpu affinity => enabled spinlock => enabled rwlock => enabled async http/websocket client => enabled Linux Native AIO => enabled pcre => enabled zlib => enabled mutex_timedlock => enabled pthread_barrier => enabled

    Directive => Local Value => Master Value swoole.aio_thread_num => 2 => 2 swoole.display_errors => On => On swoole.use_namespace => Off => Off swoole.fast_serialize => Off => Off swoole.unixsock_buffer_size => 8388608 => 8388608