-
Install packages CacheHandlerPlugin, CacheHandlerPlugin.Realm, CacheHandlerPlugin.Connectivity
-
Create handler instance
var handler = new CacheMessageHandler( %your_current_handler_instance%, apiCacheService, connectionService);
where
var apiCacheService = new RealmApiCacheService(new RealmRepository(null));
or your own
IApiCacheService
implementation (and you don't need CacheHandlerPlugin.Realm package)and
var connectionService = new ConnectivityService();
or your own
IConnectivityService
implementation (and you don't need CacheHandlerPlugin.Connectivity package) -
Create HttpClient instance
var httpClient = new HttpClient(handler);
-
Register
RequestCacheSettings
in your own or defaultICacheSettingsContainer
implementation or add cache settings in request message propertiesvar cacheSettingsContainer = new SimpleCacheSettingsContainer(); var requestMessage = new HttpRequestMessage(HttpMethod.Get, %url%); cacheSettingsContainer.Register(requestMessage, new RequestCacheSettings(600));
or
var requestMessage = new HttpRequestMessage(HttpMethod.Get, %url%); requestMessage.Properties.Add(CacheMessageHandler.CachedKey, new RequestCacheSettings(600));
-
...
-
PROFIT!
-
Notifications
You must be signed in to change notification settings - Fork 0
Simple cache for http requests
License
pocheshire/Xamarin.CacheHttpHandler
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
Simple cache for http requests
Topics
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published