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.

- (void)getWithKey:(NSString * _Nonnull)key responseHandler:^(id _Nonnull)responseHandler errorHandler:^(Fault * _Nonnull)errorHandler;
func get(key: String, responseHandler: ((Any?) -> Void)!, errorHandler: ((Fault) -> Void)!)


Argument                Description
key identifies the object to retrieve from cache.


[Backendless.shared.cache getWithKey:@"CacheWeather" responseHandler:^(Weather *weather) {
    NSLog(@"Object has been received from cache: %@", weather);
} errorHandler:^(Fault *fault) {
    NSLog(@"Error: %@", fault.message);
Backendless.shared.cache.get(key: "CacheWeather", ofType: Weather.self, responseHandler: { weather in
    print("Object has been received from cache: \(weather)")
}, errorHandler: { fault in
    print("Error: \(fault.message ?? "")")