8000 GitHub - jerily/ksuid-tcl: TCL module for K-Sortable Unique Identifiers (KSUIDs).
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

jerily/ksuid-tcl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ksuid-tcl

TCL module for K-Sortable Unique Identifiers (KSUIDs). A TCL/C implementation of Segment's KSUID library.

What is a KSUID?

KSUID is for K-Sortable Unique IDentifier. It is a kind of globally unique identifier similar to a UUID, built from the ground-up to be "naturally" sorted by generation timestamp without any special type-aware logic. In short, running a set of KSUIDs through the UNIX sort command will result in a list ordered by generation time.

Examples

package require ksuid

set ksuid [::ksuid::generate_ksuid]
# 2VDWAizIu0qTXiApIPdt5yQ9LkT

string length $ksuid
# 27

set parts [::ksuid::ksuid_to_parts $ksuid]
# timestamp 294370989 payload 4e7d497583a45e54c098a51a275ca62d

::ksuid::parts_to_ksuid $parts
# 2VDWAizIu0qTXiApIPdt5yQ9LkT

Build for TCL

wget https://github.com/jerily/ksuid-tcl/archive/refs/tags/v1.0.3.tar.gz
tar -xzf v1.0.3.tar.gz
cd ksuid-tcl-1.0.3
export KSUID_TCL_DIR=`pwd`
mkdir build
cd build
# change "TCL_LIBRARY_DIR" and "TCL_INCLUDE_DIR" to the correct paths
cmake .. \
  -DTCL_LIBRARY_DIR=/usr/local/lib \
  -DTCL_INCLUDE_DIR=/usr/local/include
make
# IMPORTANT: run the tests to make sure
# everything is working fine on your system
make test
make install

Build for NaviServer

cd ${KSUID_TCL_DIR}
make
make install

TCL Commands

  • ::ksuid::generate_ksuid
    • returns a ksuid
  • ::ksuid::ksuid_to_parts ksuid
    • returns a dict of the parts (timestamp and hex-encoded payload) of the ksuid
  • ::ksuid::parts_to_ksuid parts_dict
    • returns a ksuid from a dict of the parts (timestamp and hex-encoded payload) of the ksuid
  • ::ksuid::next_ksuid ksuid
    • returns the next ksuid
  • ::ksuid::prev_ksuid ksuid
    • returns the previous ksuid
  • ::ksuid::hex_encode bytes
    • returns a hex-encoded string
  • ::ksuid::hex_decode hex_string
    • returns a bytes object

About

TCL module for K-Sortable Unique Identifiers (KSUIDs).

Resources

License

Stars

Watchers

Forks

Packages

No packages published
0