/// <summary> /// Saves a FileCacheIndex object to the cache /// </summary> /// <param name="requestUrl"></param> /// <param name="file"></param> /// <param name="config"></param> /// <param name="checksum"></param> public static async Task saveAsync(string requestUrl, Stream file, IonConfig config, string checksum) { if (file == null) { return; } if (checksum == null) { checksum = "sha256:" + HashUtils.GetSHA256Hash(file); } FileCacheIndex cacheIndex = new FileCacheIndex(requestUrl, checksum, DateTimeUtils.now()); await CacheIndexStore.save(requestUrl, cacheIndex, config).ConfigureAwait(false); }
/// <summary> /// Retrieves a FileCacheIndex from cache /// </summary> /// <param name="requestURL"></param> /// <param name="collectionIdentifier"></param> /// <returns>FileCacheIndex object or null, if the index isn't found</returns> public static async Task <FileCacheIndex> retrieveAsync(string requestUrl, IonConfig config) { return(await CacheIndexStore.retrieve <FileCacheIndex>(requestUrl, config).ConfigureAwait(false)); }
/// <summary> /// Saves a pageCacheIndex to cache /// </summary> /// <param name="page"></param> /// <param name="config"></param> public static async Task save(IonPage page, IonConfig config) { string url = PagesURLs.getPageURL(config, page.identifier); PageCacheIndex cacheIndex = new PageCacheIndex(url, page.last_changed); await CacheIndexStore.save <PageCacheIndex>(url, cacheIndex, config).ConfigureAwait(false); }
/// <summary> /// Used to get a pageCacheIndex from cache /// </summary> /// <param name="requestURL"></param> /// <param name="collectionIdentifier"></param> /// <returns></returns> public static async Task <PageCacheIndex> retrieve(string requestURL, IonConfig config) { return(await CacheIndexStore.retrieve <PageCacheIndex>(requestURL, config).ConfigureAwait(false)); }
/// <summary> /// Saves a collectionCacheIndex to cache /// </summary> /// <param name="config"></param> /// <param name="lastModified"></param> public static async Task save(IonConfig config, DateTime lastModified) { string collectionURL = PagesURLs.getCollectionURL(config); CollectionCacheIndex cacheIndex = new CollectionCacheIndex(collectionURL, DateTimeUtils.now().ToUniversalTime(), lastModified); await CacheIndexStore.save(collectionURL, cacheIndex, config).ConfigureAwait(false); }
/// <summary> /// Retrieves a collection cache index either from memory or file cache /// </summary> /// <param name="config"></param> /// <returns>Cache index or null, if no cache index was found</returns> public static async Task <CollectionCacheIndex> retrieve(IonConfig config) { String requestUrl = PagesURLs.getCollectionURL(config); return(await CacheIndexStore.retrieve <CollectionCacheIndex>(requestUrl, config).ConfigureAwait(false)); }