Interface IUriLoaderCache
Interface for Caches that can be used to cache the result of loading Graphs from URIs.
Namespace: VDS.RDF.Parsing
Assembly: dotNetRdf.dll
Syntax
public interface IUriLoaderCache
Remarks
Warning: Only available in Builds for which caching is supported e.g. not supported under Silverlight.
Implementors should take care to implement their caches such that any errors in the cache do not bubble up outside of the cache. If the cache encounters any error when caching data or retrieving data from the cache it should indicate that the cached data is not available.
Properties
| Edit this page View SourceCacheDirectory
Gets/Sets the Cache Directory that is in use.
Declaration
string CacheDirectory { get; set; }
Property Value
Type | Description |
---|---|
string |
Remarks
Non-filesystem based caches are free to return String.Empty or null but MUST NOT throw any form or error.
CacheDuration
Gets/Sets how long results should be cached.
Declaration
TimeSpan CacheDuration { get; set; }
Property Value
Type | Description |
---|---|
TimeSpan |
Remarks
This only applies to downloaded URIs where an ETag is not available, where ETags are available ETag based caching SHOULD be used.
Methods
| Edit this page View SourceClear()
Clears the Cache.
Declaration
void Clear()
GetETag(Uri)
Gets the ETag for the given URI.
Declaration
string GetETag(Uri u)
Parameters
Type | Name | Description |
---|---|---|
Uri | u | URI. |
Returns
Type | Description |
---|---|
string |
Remarks
Calling code MUST always use the HasETag() method prior to using this method so it should be safe to throw the KeyNotFoundException if there is no ETag for the given URI.
Exceptions
Type | Condition |
---|---|
KeyNotFoundException | Thrown if there is no ETag for the given URI. |
GetLocalCopy(Uri)
Gets the path to the locally cached copy of the Graph from the given URI.
Declaration
string GetLocalCopy(Uri u)
Parameters
Type | Name | Description |
---|---|---|
Uri | u | URI. |
Returns
Type | Description |
---|---|
string |
HasETag(Uri)
Gets whether there is an ETag for the given URI.
Declaration
bool HasETag(Uri u)
Parameters
Type | Name | Description |
---|---|---|
Uri | u | URI. |
Returns
Type | Description |
---|---|
bool |
HasLocalCopy(Uri, bool)
Is there a locally cached copy of the Graph from the given URI which is not expired.
Declaration
bool HasLocalCopy(Uri u, bool requireFreshness)
Parameters
Type | Name | Description |
---|---|---|
Uri | u | URI. |
bool | requireFreshness | Whether the local copy is required to meet the Cache Freshness (set by the Cache Duration). |
Returns
Type | Description |
---|---|
bool |
RemoveETag(Uri)
Remove the ETag record for the given URI.
Declaration
void RemoveETag(Uri u)
Parameters
Type | Name | Description |
---|---|---|
Uri | u | URI. |
RemoveLocalCopy(Uri)
Removes a locally cached copy of a URIs results from the Cache.
Declaration
void RemoveLocalCopy(Uri u)
Parameters
Type | Name | Description |
---|---|---|
Uri | u | URI. |
ToCache(Uri, Uri, string)
Associates an ETag (if any) with the Request and Response URIs plus returns an IRdfHandler that can be used to write to the cache.
Declaration
IRdfHandler ToCache(Uri requestUri, Uri responseUri, string etag)
Parameters
Type | Name | Description |
---|---|---|
Uri | requestUri | URI from which the RDF Graph was requested. |
Uri | responseUri | The actual URI which responded to the request. |
string | etag | ETag of the response (if any). |
Returns
Type | Description |
---|---|
IRdfHandler | Either an instance of an IRdfHandler that will do the caching or null if no caching is possible. |