Retrieving data from cache¶
This API request retrieves an object from Backendless cache. If object is not present in cache, the method returns null for complex types or default value for primitive values. All methods are available via Backendless.Cache.[methodname]
accessor:
// synchronous method
public T Get<T>( String key )
// asynchronous method
public void Get<T>( String key, AsyncCallback callback );
where:
Argument | Description |
---|---|
key |
identifies the object to retrieve from cache. |
callback |
the callback used for asynchronous calls to deliver object from cache or error. |
Example¶
AsyncCallback<Order> callback = new AsyncCallback<Order>(
result =>
{
System.Console.WriteLine( "received order object from cache - " + result.Name );
},
fault =>
{
System.Console.WriteLine( "Error - " + fault );
} );
// get object from cache asynchronously
Backendless.Cache.Get<Order>( "firstorder", callback );
// get object from cache synchronously
Order order = Backendless.Cache.Get<Order>( "firstorder" );
Codeless Reference¶
where:
Argument | Description |
---|---|
key name |
Key assigned to the object to identify it in cache. The key is used to retrieve the object from cache or to check if the cache still contains the object. |
Returns a value associated with the requested key.
Consider the following key-value pair stored in cache:
The example below retrieves the value of the key "orderName"
stored in cache.
The result of this operation will look as shown below after the Codeless logic runs: