Game Jolt Unity API  v2.5.8
Static Public Member Functions | Public Attributes | List of all members
GameJolt.API.DataStore Class Reference

The DataStore API methods. More...

Static Public Member Functions

static void Set (string key, string value, bool global, Action< bool > callback=null)
 Save the key/value pair in the DataStore. Caution: GameJolt refuses requests with a payload of more than 1MB. The payload is composed of the key, the value and 10 bytes of meta data. Use SetSegmented for data larger than 1MB. More...
 
static void SetSegmented (string key, string value, bool global, Action< bool > callback, Action< int > progress=null, int maxSegmentSize=SoftLimit)
 Caution: Non atomic operation! Save the key/value pair in the DataStore. This method will split the payload into multiple smaller packages, in order to overcome GameJolts 1MB limit. These packages will be appended via the update operation. If one or more parts are already uploaded and then an error occurs (for e.g. no network connection), this method will stop uploading further packages. If this happens the DataStore might contain incomplete data, therefore you might want to delete the entry or try uploading again. By using the progress callback, you could also try to continue from the last position. More...
 
static void Update (string key, string value, DataStoreOperation operation, bool global, Action< string > callback=null)
 Update the value for a given key in the DataStore. More...
 
static void Get (string key, bool global, Action< string > callback)
 Get the value for a given key from the DataStore. More...
 
static void Delete (string key, bool global, Action< bool > callback=null)
 Delete the key from the DataStore. More...
 
static void GetKeys (bool global, Action< string[]> callback)
 Gets the list of available keys in the DataStore. More...
 
static void GetKeys (bool global, string pattern, Action< string[]> callback)
 Gets the list of available keys in the DataStore. More...
 

Public Attributes

const int SoftLimit = 1024 * 1024 - 11
 GameJolt refuses requests larger than this. In order for an operation to succeed the encoded key length + encoded value length must not be larger than this. More...
 
const int HardLimit = 16777000
 GameJolt allows only about 16MB per key-value pair. More...
 
const int KeySizeLimit = SoftLimit - 1024
 Maximum size for dataset key. More...
 

Detailed Description

The DataStore API methods.

Member Function Documentation

◆ Delete()

static void GameJolt.API.DataStore.Delete ( string  key,
bool  global,
Action< bool >  callback = null 
)
inlinestatic

Delete the key from the DataStore.

Parameters
keyThe key name.
globalA boolean indicating whether the key is global (true) or private to the user (false).
callbackA callback function accepting a single parameter, a boolean indicating success.

◆ Get()

static void GameJolt.API.DataStore.Get ( string  key,
bool  global,
Action< string >  callback 
)
inlinestatic

Get the value for a given key from the DataStore.

Parameters
keyThe key name.
globalA boolean indicating whether the key is global (true) or private to the user (false).
callbackA callback function accepting a single parameter, the key value.

◆ GetKeys() [1/2]

static void GameJolt.API.DataStore.GetKeys ( bool  global,
Action< string[]>  callback 
)
inlinestatic

Gets the list of available keys in the DataStore.

Parameters
globalA boolean indicating whether the keys are global (true) or private to the user (false).
callbackA callback function accepting a single parameter, a list of key names.

◆ GetKeys() [2/2]

static void GameJolt.API.DataStore.GetKeys ( bool  global,
string  pattern,
Action< string[]>  callback 
)
inlinestatic

Gets the list of available keys in the DataStore.

Parameters
globalA boolean indicating whether the keys are global (true) or private to the user (false).
patternOnly keys matching this pattern will be returned. Placeholder character is *
callbackA callback function accepting a single parameter, a list of key names.

◆ Set()

static void GameJolt.API.DataStore.Set ( string  key,
string  value,
bool  global,
Action< bool >  callback = null 
)
inlinestatic

Save the key/value pair in the DataStore. Caution: GameJolt refuses requests with a payload of more than 1MB. The payload is composed of the key, the value and 10 bytes of meta data. Use SetSegmented for data larger than 1MB.

Parameters
keyThe key name.
valueThe value to store.
globalA boolean indicating whether the key is global (true) or private to the user (false).
callbackA callback function accepting a single parameter, a boolean indicating success.

◆ SetSegmented()

static void GameJolt.API.DataStore.SetSegmented ( string  key,
string  value,
bool  global,
Action< bool >  callback,
Action< int >  progress = null,
int  maxSegmentSize = SoftLimit 
)
inlinestatic

Caution: Non atomic operation! Save the key/value pair in the DataStore. This method will split the payload into multiple smaller packages, in order to overcome GameJolts 1MB limit. These packages will be appended via the update operation. If one or more parts are already uploaded and then an error occurs (for e.g. no network connection), this method will stop uploading further packages. If this happens the DataStore might contain incomplete data, therefore you might want to delete the entry or try uploading again. By using the progress callback, you could also try to continue from the last position.

Parameters
keyThe key name.
valueThe value to store.
globalA boolean indicating whether the key is global (true) or private to the user (false).
callbackA callback function accepting a single parameter, a boolean indicating success.
progressA callback function accepting a single parameter, the number of already uploaded bytes. This callback is called after each successfull segment upload.
maxSegmentSizeMaximum segment size. The data to upload is split into segments of at most this size.

◆ Update()

static void GameJolt.API.DataStore.Update ( string  key,
string  value,
DataStoreOperation  operation,
bool  global,
Action< string >  callback = null 
)
inlinestatic

Update the value for a given key in the DataStore.

Parameters
keyThe key name.
valueThe new value to operate with.
operationThe DataStoreOperation to perform.
globalA boolean indicating whether the key is global (true) or private to the user (false).
callbackA callback function accepting a single parameter, a the updated key value.

Member Data Documentation

◆ HardLimit

const int GameJolt.API.DataStore.HardLimit = 16777000

GameJolt allows only about 16MB per key-value pair.

◆ KeySizeLimit

const int GameJolt.API.DataStore.KeySizeLimit = SoftLimit - 1024

Maximum size for dataset key.

◆ SoftLimit

const int GameJolt.API.DataStore.SoftLimit = 1024 * 1024 - 11

GameJolt refuses requests larger than this. In order for an operation to succeed the encoded key length + encoded value length must not be larger than this.


The documentation for this class was generated from the following file: