搜尋套件、儲存庫與 APP 分類

套件詳情v2.2.0

ulid

字典序可排序的128位識別碼(UUID),包含48位時間戳和80位隨機位。標準編碼為26個字元的字串,而非36個字元的UUID。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
3.2萬
喜歡數
56
Pub 分數
160

安裝套件

flutter pub add ulid

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

ULID 是一種 128 位識別碼,結合了 48 位時間戳與 80 位隨機位,產生可字典順序排序的 ID。編碼為 26 字元字串,提供比標準 UUID(36 字元)更緊湊的替代方案。ULID 非常適合需要唯一且時間有序識別碼的分散式系統,無需依賴集中式協調。該套件支援多種平台,包括 Android、iOS、Web、macOS、Windows 與 Linux。

適用情境

  • 分散式系統識別碼
  • 時間順序的數據追蹤
  • 資料庫主鍵
  • API 請求追蹤
  • 安全會話令牌
  • 日誌條目識別

主要特色

  • 字典序可排序
  • 緊湊的26字元編碼
  • 內建時間戳
  • 高熵,80個隨機位
  • 跨平台支援
  • 無對外部服務的依賴

適合對象

  • 需要時間順序唯一性的應用程式
  • 避免中心化ID生成的系統
  • 高性能資料庫
  • 事件溯源架構
  • 具有去中心化ID的微服務需要

使用建議

  • 不適合用於加密祕密
  • 在高頻場景下需要謹慎處理
  • 受限於128位大小限制
  • 在舊系統中並非普遍支援
  • 在嚴格合規環境中可能需要驗證

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Ulid implementation in Dart

Lexicographically sortable, 128-bit identifier (UUID) with 48-bit timestamp and 80 random bits. Canonically encoded as a 26 character string, as opposed to the 36 character UUID.

Original implementation: https://github.com/alizain/ulid/

Specification: https://github.com/ulid/spec

Usage

A simple usage example:

import 'package:ulid/ulid.dart';

void main() {
  print(Ulid());
  print(Ulid().toUuid());
  print(Ulid().toCanonical());
  print(Ulid().toBase32()); // uppercase, spec-aligned format
}

Links

所屬分類

原始碼儲存庫

使用此套件的專案

所在榜單