C# Class Scalien.Sequence

Sequence is a class for atomically retrieving unique integer IDs using a key whose value stores the next ID as a piece of text. The first returned ID is 1.

ScalienDB is a key value store, so unique IDs have to be maintained in a separate key in a seperate table. For example:

people => 2500

In this case, the next sequence value returned would be 2500.

ScalienDB has a special ADD command which parses the value as a number and increments it by a user specified value. The Index class wraps this functionality, and increments the number by a user-defined gran (default 1000). This way, the server is contacted only every 1000th time the sequence is incremented, which is an important optimization since sending and waiting for commands to execute on the server is slow.

Note that if the client quits before using up all the sequence values retrieved by the last ADD command, those will not be passed out, and there will be a hole in the sequence.

Use Reset() to reset the sequence to 1. This sets:

key => 1

Mostrar archivo Open project: scalien/scaliendb Class Usage Examples

Public Methods

Method Description
Reset ( ) : void

Reset the sequence to 1. The next time GetNext is called, 1 will be returned.

This sets:

key => 1

Set ( ulong value ) : void

Set the sequence to a given value. The next time GetNext is called, value will be returned.

This sets:

key => value

Private Methods

Method Description
Sequence ( Scalien.Client client, ulong tableID, byte key ) : System
Sequence ( Scalien.Client client, ulong tableID, string key ) : System
SetGranularity ( long gran ) : void

Method Details

Reset() public method

Reset the sequence to 1. The next time GetNext is called, 1 will be returned.
This sets:

key => 1

public Reset ( ) : void
return void

Set() public method

Set the sequence to a given value. The next time GetNext is called, value will be returned.
This sets:

key => value

public Set ( ulong value ) : void
value ulong
return void