iMac14,2 ubench

Model Name: iMac
Model Identifier: iMac14,2
Processor Name: Intel Core i5
Processor Speed: 3.2 GHz
Number of Processors: 1
Total Number of Cores: 4
L2 Cache (per Core): 256 KB
L3 Cache: 6 MB
Memory: 8 GB
Boot ROM Version: IM142.0130.B00
SMC Version (system): 2.15f7

Unix Benchmark Utility v.0.3
Copyright (C) July, 1999 PhysTech, Inc.
Author: Sergei Viznyuk
http://www.phystech.com/download/ubench.html
Darwin 18.0.0 Darwin Kernel Version 18.0.0: Wed Aug 22 20:13:40 PDT 2018; root:xnu-4903.201.2~1/RELEASE_X86_64 x86_64
Ubench CPU: 2000384
Ubench MEM: 1414788
——————–
Ubench AVG: 1707586

Advertisements

#imac, #intel-core-i5, #ubench

利用 MySQL 自增列生成订单号

在 MySQL 里创建一个带有自增列的表,使用 MEMORY ENGINE 存储即可。
利用时间生成字符串,后面再加上自增列生成的数字,根据业务容量仅取最后几位,示例代码仅取后4位。

<?php
namespace app\api\service;

/**
 * CREATE TABLE IF NOT EXISTS `order_id_seq` (
 *     id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
 *     PRIMARY KEY (`id`)
 * ) ENGINE=MEMORY AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
 */
class OrderIdService {

    /**
     * Returns next order ID.
     *
     * @return string
     */
    public function nextId() {
        $seq = $this->nextSeq();
        $id = date('YmdHis') . sprintf('%04d', $seq % 10000);
        return $id;
    }

    /**
     * Returns next sequence number.
     *
     * @return number
     */
    private function nextSeq() {
        $db = \think\Db::connect('db_platform');
        $seq = $db->table('order_id_seq')->insertGetId(['id' => 0]);
        $db->table('order_id_seq')->where('id', $seq)->delete();
        return $seq;
    }

}