tiny-blocks/ksuid
Composer 安装命令:
composer require tiny-blocks/ksuid
包简介
K-Sortable Unique Identifier.
README 文档
README
Overview
Ksuid stands for K-Sortable Unique Identifier. It's a way to generate globally unique IDs which are partially chronologically sortable.
Installation
composer require tiny-blocks/ksuid
How to use
The library exposes a concrete implementation through the Ksuid class.
Creating a Ksuid
With the random method, a new instance of type Ksuid is created from a timestamp (current unix timestamp - EPOCH)
and a payload (cryptographically secure pseudo-random bytes).
<?php declare(strict_types=1); use TinyBlocks\Ksuid\Ksuid; $ksuid = Ksuid::random(); $ksuid->value(); # 2QzPUGEaAKHhVcQYrqQodbiZat1 $ksuid->payload(); # 464932c1194da98e752145d72b8f0aab $ksuid->unixTime(); # 1686353450 $ksuid->timestamp(); # 286353450
You can also choose from other factory models.
Ksuid::from(payload: hex2bin('9850EEEC191BF4FF26F99315CE43B0C8'), timestamp: 286235327); Ksuid::fromPayload(value: '0o5Fs0EELR0fUjHjbCnEtdUwQe3'); Ksuid::fromTimestamp(value: 286235327);
Inspecting a Ksuid
You can inspect the components used to create a Ksuid, using the inspectFrom method.
$ksuid = Ksuid::inspectFrom(ksuid: '2QzPUGEaAKHhVcQYrqQodbiZat1');
This will output the following array:
[
'time' => '2023-06-09 20:30:50 -0300 -03',
'payload' => '464932c1194da98e752145d72b8f0aab',
'timestamp' => 286353450
]
License
Ksuid is licensed under MIT.
Contributing
Please follow the contributing guidelines to contribute to the project.
tiny-blocks/ksuid 适用场景与选型建议
tiny-blocks/ksuid 是一款 基于 Python 开发的 Composer 扩展包,目前已累计 88.42k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2023 年 06 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「tiny-blocks」 「ksuid」 「unique-identifier」 「k-sortable」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 tiny-blocks/ksuid 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tiny-blocks/ksuid 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 tiny-blocks/ksuid 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Models ISO-4217 currencies as a PHP enum, with per-currency fraction digit resolution.
Provides ISO 3166-1 country and ISO 3166-2 subdivision value objects for PHP, with Alpha-2, Alpha-3, numeric, and IANA timezone resolution.
UUID (RFC 9562), ULID, Snowflake ID, Sonyflake ID, and TBSL generator for PHP.
Use Stripe-like IDs for your models.
Provides configurable and customizable Stripe-like keys for your Eloquent models
Models time as immutable value objects for PHP: instants, durations, periods, timezones, and time-of-day, all UTC-normalized.
统计信息
- 总下载量: 88.42k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 41
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-06-08