承接 odan/tsid 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

odan/tsid

最新稳定版本:0.1.0

Composer 安装命令:

composer require odan/tsid

包简介

A library for generating Time Sortable Identifiers (TSID).

关键字:

README 文档

README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

Description

A library for generating Time Sortable Identifiers (TSID).

This library is a port of TSID Creator from Java to PHP.

Requirements

  • PHP 8.0+

Installation

composer require odan/tsid

Usage

use Odan\Tsid\TsidFactory;

$tsidFactory = new TsidFactory();

$tsid = $tsidFactory->generate();

// 388400145978465528
echo $tsid->toInt();

// 0ARYZVZXW377R
echo $tsid->toString();

Database Usage

MySQL

Use bigint(20) unsigned as datatype for the (primary / secondary) key.

Example:

CREATE TABLE `users` (
    `id` bigint(20) unsigned NOT NULL,
    `username` varchar(45) NOT NULL,
     PRIMARY KEY (`id`)
) ENGINE=InnoDB

Note: When you use BIGINT(20) the maximum value is 2^63 - 1 == 9223372036854775807. This means there is still enough space to store any TSID. When you use BIGINT(20) unsigned the maximum value is: 2^64-1 = 18446744073709551615

SQLite

Use INTEGER as datatype for the (primary / secondary) key.

CREATE TABLE users (id INTEGER PRIMARY KEY, username TEXT);

Note: SQLite uses an 8-byte signed integer to store integers. So the maximum positive integer value is 2^63 - 1 == 9223372036854775807. This means there is still enough space to store any TSID.

Data Type Comparison

TSID max:                          18446744073709551615
TSID 2023-01-01T00:00:00.000Z:       397177100698290050
TSID 2038-01-19T03:14:07.000Z:      2389272048961164191
TSID 2999-12-31T23:59:59.999Z:      7015104302283010234
PHP_INT_MAX:                        9223372036854775807
SQLite INTEGER max:                 9223372036854775807
MySQL BIGINT(20) max:               9223372036854775807
MySQL BIGINT(20) unsigned max:     18446744073709551615

Read more

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 205.4k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 24
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 24
  • Watchers: 1
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04