Skip to content

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> T get( String key, Class<? extends T> type );

// asynchronous method
public <T> void get( final String key, final AsyncCallback<T> callback )


Argument                Description
key identifies the object to retrieve from cache.
callback the callback used for asynchronous calls to deliver object from cache or error.


AsyncCallback<Order> callback = new AsyncCallback<Order>()
      public void handleResponse( Order order )
         Log.i( "MYAPP", "[ASYNC] retrieved order from cache - " + order.getName() );

      public void handleFault( BackendlessFault backendlessFault )
        Log.e( "MYAPP", "Error - " + backendlessFault.getMessage() );

    // get object from cache asynchronously
    Backendless.Cache.get( "firstorder", callback );

    // get object from cache synchronously
    Order order = Backendless.Cache.get( "firstorder", Order.class );
    Log.i( "MYAPP", "[SYNC] retrieved order from cache - " + order.getName() );