Common Lisp Package: CL-MONGO-ID

README:

FUNCTION

Public

GET-HOSTNAME (OID &KEY BYTES)

Grab the hostname int out of a vector oid. Passing :bytes t will return an array of bytes corresponding to the hostname part of the ID instead of parsing it as an integer.

GET-INC (OID &KEY BYTES)

Grab the inc value out of a vector oid. Passing :bytes t will return an array of bytes corresponding to the inc value of the ID instead of parsing it as an integer.

GET-PID (OID &KEY BYTES)

Grab the pid out of a vector oid. Passing :bytes t will return an array of bytes corresponding to the PID part of the ID instead of parsing it as an integer.

GET-TIMESTAMP (OID &KEY BYTES)

Grab the timestamp out of a vector oid. Passing :bytes t will return an array of bytes corresponding to the timestamp part of the ID instead of parsing it as an integer.

OID (&OPTIONAL ID)

Generate a mongo id, in byte vector format.

OID-STR (OID)

Given a vector ID, convert it to a string.

Private

CONVERT-HEX-VECTOR (HEX-STRING)

Takes a hex string, IE 4f2b8096 and converts it into a byte array: 4f2b8096 -> #(79 43 128 150) Hex string *must* have even number of bytes.

CONVERT-VECTOR-INT (VECTOR)

Convert a byte array to an integer: #(79 150 243 81) -> 1335292753

CREATE-NEW-ID

Create a brand-spankin-new ObjectId using the current timestamp/inc values, along with hostname and process pid.

GET-CURRENT-HOSTNAME

Get hostname of machine.

GET-CURRENT-PID (&KEY IF-NOT-EXISTS-RETURN)

Get the current process' PID. This function does it's best to be cross- implementation. If it isn't able to grab the PID from the system, it defaults to returning whatever value is passed into the :if-not-exists-return key.

GET-CURRENT-TIMESTAMP

Get current unix timestamp.

GET-INC-VAL

Thread-safe method to get current ObjectId inc value. Takes an optional timestamp value to calculate inc for.

VARIABLE

Private

Undocumented

*ID-INC*

*ID-INC-LOCK*