public DiskBackend(string filename, long filesize, ICacheBackend fallback) { this.fallback = fallback; usedSize = 0; maxFileSize = filesize; FileInfo fi = new FileInfo(filename); FreeList.AddLast(new FileSegment(0, long.MaxValue)); dataFile = filename; indexFile = dataFile + ".index"; // create the file if it doesnt exist if (!File.Exists(filename)) { using (FileStream fs = File.Create(filename)) { // do nothing } } try { LoadIndex(); } catch (Exception ex) { Console.WriteLine(ex); // clear the index data.Clear(); FreeList.Clear(); FreeList.AddLast(new FileSegment(0, long.MaxValue)); } }
public void Dispose() { if (backend is IDisposable) { ((IDisposable)backend).Dispose(); } backend = null; }
public AbstractCacheFrontend(string identifier, ICacheBackend backend) { this.identifier = identifier; this.backend = backend; }
public MemoryBackend(int max, ICacheBackend fb) { this.max = max; fallback = fb; }
public StringFrontend(string identifier, ICacheBackend backend) : base(identifier, backend) { }
public Cache(ICacheBackend backend) { this.backend = backend; }