Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 114 lines (102 sloc) 4.881 kb
c61746f Paul Betts Initial import
paulcbetts authored
1 using System;
2 using System.Collections.Generic;
734425e Paul Betts Abstract away file operations
paulcbetts authored
3 using System.IO;
30614b9 Paul Betts Add the initial test for cache expiration
paulcbetts authored
4 using System.Reactive.Concurrency;
c61746f Paul Betts Initial import
paulcbetts authored
5
6 namespace Akavache
7 {
d20bb1a Paul Betts Document core interfaces as well as Blob cache extensions
paulcbetts authored
8 /// <summary>
9 /// An abstraction for the simple file operations that an IBlobCache can
10 /// perform. Create a new instance of this when adapting IBlobCache to
11 /// different platforms or backing stores, or for testing purposes.
12 /// </summary>
734425e Paul Betts Abstract away file operations
paulcbetts authored
13 public interface IFilesystemProvider
14 {
d20bb1a Paul Betts Document core interfaces as well as Blob cache extensions
paulcbetts authored
15 /// <summary>
16 /// Open a file on a background thread, with the File object in 'async
17 /// mode'. It is critical that this operation is deferred and returns
18 /// immediately (i.e. wrapped in an Observable.Start).
19 /// </summary>
20 /// <param name="path">The path to the file</param>
21 /// <param name="mode">The file mode</param>
22 /// <param name="access">The required access privileges</param>
23 /// <param name="share">The allowed file sharing modes.</param>
89ed763 Paul Betts Fix race condition where PersistentBlobCache wasn't guaranteeing objects
paulcbetts authored
24 /// <param name="scheduler">The scheduler to schedule the open under.</param>
d20bb1a Paul Betts Document core interfaces as well as Blob cache extensions
paulcbetts authored
25 /// <returns>A Future result representing the Open file.</returns>
89ed763 Paul Betts Fix race condition where PersistentBlobCache wasn't guaranteeing objects
paulcbetts authored
26 IObservable<Stream> SafeOpenFileAsync(string path, FileMode mode, FileAccess access, FileShare share, IScheduler scheduler);
d20bb1a Paul Betts Document core interfaces as well as Blob cache extensions
paulcbetts authored
27
28 /// <summary>
29 /// Create a directory and its parents. If the directory already
30 /// exists, this method does nothing (i.e. it does not throw if a
31 /// directory exists)
32 /// </summary>
33 /// <param name="path">The path to create.</param>
734425e Paul Betts Abstract away file operations
paulcbetts authored
34 void CreateRecursive(string path);
d20bb1a Paul Betts Document core interfaces as well as Blob cache extensions
paulcbetts authored
35
36 /// <summary>
37 /// Deletes a file.
38 /// </summary>
39 /// <param name="path">The path to the file</param>
734425e Paul Betts Abstract away file operations
paulcbetts authored
40 void Delete(string path);
41 }
42
d20bb1a Paul Betts Document core interfaces as well as Blob cache extensions
paulcbetts authored
43 /// <summary>
44 /// IBlobCache is the core interface on which Akavache is built, it is an
45 /// interface describing an asynchronous persistent key-value store.
46 /// </summary>
c61746f Paul Betts Initial import
paulcbetts authored
47 public interface IBlobCache : IDisposable
48 {
d20bb1a Paul Betts Document core interfaces as well as Blob cache extensions
paulcbetts authored
49 /// <summary>
50 /// Insert a blob into the cache with the specified key and expiration
51 /// date.
52 /// </summary>
53 /// <param name="key">The key to use for the data.</param>
54 /// <param name="data">The data to save in the cache.</param>
55 /// <param name="absoluteExpiration">An optional expiration date.
56 /// After the specified date, the key-value pair should be removed.</param>
30614b9 Paul Betts Add the initial test for cache expiration
paulcbetts authored
57 void Insert(string key, byte[] data, DateTimeOffset? absoluteExpiration = null);
d20bb1a Paul Betts Document core interfaces as well as Blob cache extensions
paulcbetts authored
58
59 /// <summary>
60 /// Retrieve a value from the key-value cache. If the key is not in
61 /// the cache, this method should return an IObservable which
62 /// OnError's with KeyNotFoundException.
63 /// </summary>
64 /// <param name="key">The key to return asynchronously.</param>
65 /// <returns>A Future result representing the byte data.</returns>
c61746f Paul Betts Initial import
paulcbetts authored
66 IObservable<byte[]> GetAsync(string key);
d20bb1a Paul Betts Document core interfaces as well as Blob cache extensions
paulcbetts authored
67
68 /// <summary>
69 /// Return all keys in the cache. Note that this method is normally
70 /// for diagnostic / testing purposes, and that it is not guaranteed
71 /// to be accurate with respect to in-flight requests.
72 /// </summary>
73 /// <returns>A list of valid keys for the cache.</returns>
c61746f Paul Betts Initial import
paulcbetts authored
74 IEnumerable<string> GetAllKeys();
d20bb1a Paul Betts Document core interfaces as well as Blob cache extensions
paulcbetts authored
75
76 /// <summary>
10d519d Paul Betts Implement GetCreatedAt on IBlobCache
paulcbetts authored
77 /// Returns the time that the key was added to the cache, or returns
78 /// null if the key isn't in the cache.
79 /// </summary>
80 /// <param name="key">The key to return the date for.</param>
81 /// <returns>The date the key was created on.</returns>
82 IObservable<DateTimeOffset?> GetCreatedAt(string key);
83
84 /// <summary>
d20bb1a Paul Betts Document core interfaces as well as Blob cache extensions
paulcbetts authored
85 /// Remove a key from the cache. If the key doesn't exist, this method
1022b4a Paul Betts Merge remote-tracking branch 'origin/ghforwin-hax'
paulcbetts authored
86 /// should do nothing and return (*not* throw KeyNotFoundException).
d20bb1a Paul Betts Document core interfaces as well as Blob cache extensions
paulcbetts authored
87 /// </summary>
88 /// <param name="key">The key to remove from the cache.</param>
c61746f Paul Betts Initial import
paulcbetts authored
89 void Invalidate(string key);
d20bb1a Paul Betts Document core interfaces as well as Blob cache extensions
paulcbetts authored
90
91 /// <summary>
92 /// Invalidate all entries in the cache (i.e. clear it). Note that
93 /// this method is blocking and incurs a significant performance
89ed763 Paul Betts Fix race condition where PersistentBlobCache wasn't guaranteeing objects
paulcbetts authored
94 /// penalty if used while the cache is being used on other threads.
d20bb1a Paul Betts Document core interfaces as well as Blob cache extensions
paulcbetts authored
95 /// </summary>
c61746f Paul Betts Initial import
paulcbetts authored
96 void InvalidateAll();
30614b9 Paul Betts Add the initial test for cache expiration
paulcbetts authored
97
d20bb1a Paul Betts Document core interfaces as well as Blob cache extensions
paulcbetts authored
98 /// <summary>
99 /// The IScheduler used to defer operations. By default, this is
1022b4a Paul Betts Merge remote-tracking branch 'origin/ghforwin-hax'
paulcbetts authored
100 /// RxApp.TaskPoolScheduler.
d20bb1a Paul Betts Document core interfaces as well as Blob cache extensions
paulcbetts authored
101 /// </summary>
30614b9 Paul Betts Add the initial test for cache expiration
paulcbetts authored
102 IScheduler Scheduler { get; }
c61746f Paul Betts Initial import
paulcbetts authored
103 }
665ca8f Paul Betts Add Silverlight 5 Support
paulcbetts authored
104
d20bb1a Paul Betts Document core interfaces as well as Blob cache extensions
paulcbetts authored
105 /// <summary>
106 /// This interface indicates that the underlying BlobCache implementation
107 /// encrypts or otherwise secures its persisted content.
108 ///
109 /// By implementing this interface, you must guarantee that the data
110 /// saved to disk cannot be easily read by a third party.
111 /// </summary>
112 public interface ISecureBlobCache : IBlobCache { }
113 }
Something went wrong with that request. Please try again.