public bool KeyDelete(FileBasedKey key)
            {
                if (!ContainsKey(key))
                    return false;

                File.Delete(MemoryFileFor(key));
                return true;
            }
            public bool StringSet(FileBasedKey key, FileBasedValue value, TimeSpan? expiry, When when)
            {
                if (ContainsKey(key) && when == When.NotExists)
                    return false;

                if (expiry.HasValue)
                    value = new FileBasedValueWithExpiry(value, DateTime.Now, expiry);

                this[key] = value;

                return true;
            }
 public FileBasedValueWithExpiry StringGetWithExpiry(FileBasedKey key)
 {
     return ContainsKey(key) ? this[key] as FileBasedValueWithExpiry : FileBasedValueWithExpiry.Null;
 }
 public FileBasedValue StringGet(FileBasedKey key)
 {
     return ContainsKey(key) ? this[key] : FileBasedValue.Null;
 }
 private void ClearValueIfExpired(FileBasedKey key)
 {
     var value = GetValueOfKey(key) as FileBasedValueWithExpiry;
     if (value != null && value.IsExpired)
         File.Delete(MemoryFileFor(key));
 }
 public Task<FileBasedValueWithExpiry> StringGetWithExpiryAsync(FileBasedKey key)
 {
     return Task.Run(() => StringGetWithExpiry(key));
 }
 public Task<bool> StringSetAsync(FileBasedKey key, FileBasedValue value, TimeSpan? expiry, When exists)
 {
     return Task.Run(() => StringSet(key, value, expiry, exists));
 }
 public Task<bool> KeyDeleteAsync(FileBasedKey key)
 {
     return Task.Run(() => KeyDelete(key));
 }
 private bool ContainsKey(FileBasedKey key)
 {
     EnsureFolderExists();
     ClearValueIfExpired(key);
     return File.Exists(MemoryFileFor(key));
 }