FulcrumFS FulcrumFS
FulcrumFS FulcrumFS
DocFX + Singulink = ♥

Search Results for

    Class FileIdGenerator

    Generates sequential file IDs backed by version 7 GUIDs, each greater than every ID the same generator created before it.

    Inheritance
    object
    FileIdGenerator
    Namespace: FulcrumFS
    Assembly: FulcrumFS.Core.dll
    Syntax
    public sealed class FileIdGenerator
    Remarks

    An ID holds the Unix time in milliseconds when it was created, a 4-bit counter of the IDs created within that millisecond, and 70 cryptographically random bits. Up to 16 IDs per millisecond carry the current time. Beyond that, or when the clock moves backwards, the generator moves its timestamp one millisecond ahead instead of waiting for the clock, so a sustained burst runs the embedded timestamps ahead of the clock until the rate drops again.

    IDs from one generator compare in creation order both as D format strings (ordinal comparison) and as Guid values (CompareTo(Guid)). No order is guaranteed between IDs from different generators, or between generators in successive runs of a process whose clock reads earlier than the timestamps already used. Uniqueness across generators rests on the random bits, as it does for any version 7 GUID.

    Sequential IDs are predictable and reveal when they were created (see Timestamp). Use CreateSecure() for IDs that are exposed to untrusted parties.

    Every FileRepo owns a generator of its own. Shared is the process-wide instance behind CreateSequential(); code that creates many IDs should use its own generator so that it does not contend for the shared lock or share its 16 IDs per millisecond with other callers.

    Constructors

    Name Description
    FileIdGenerator()

    Initializes a new instance of the FileIdGenerator class that reads the time from System.

    FileIdGenerator(TimeProvider)

    Initializes a new instance of the FileIdGenerator class that reads the time from the specified time provider.

    Properties

    Name Description
    Shared

    Gets the process-wide generator used by CreateSequential().

    Methods

    Name Description
    CreateSequential()

    Creates a new sequential file ID backed by a version 7 GUID that is greater than every ID previously created by this generator. This method is thread-safe.

    © Singulink. All rights reserved.