Skip to content

Commit

Permalink
Add exclusive mode to macos. Fixes #63
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmontemagno committed Jul 26, 2019
1 parent 0a97103 commit 9e53326
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/MonkeyCache.FileStore/MonkeyCache.FileStore.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="MSBuild.Sdk.Extras/1.6.61">
<Project Sdk="MSBuild.Sdk.Extras/2.0.31">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;Xamarin.WatchOS10;Xamarin.TVOS10;Xamarin.iOS10;MonoAndroid71;MonoAndroid80;MonoAndroid81;MonoAndroid90;Xamarin.Mac20;uap10.0.16299</TargetFrameworks>
Expand Down
25 changes: 17 additions & 8 deletions src/MonkeyCache.LiteDB/Barrel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,17 @@ public static IBarrel Create(string cacheDirectory)
Directory.CreateDirectory(directory);
}

#if __MACOS__

if (!string.IsNullOrWhiteSpace(EncryptionKey))
path = $"Filename={path}; Password={EncryptionKey}; Mode=Exclusive";
else
path = $"Filename={path}; Mode=Exclusive";
#else

if (!string.IsNullOrWhiteSpace(EncryptionKey))
path = $"Filename={path}; Password={EncryptionKey}";
#endif

db = new LiteDatabase(path);
col = db.GetCollection<Banana>();
Expand All @@ -59,7 +68,7 @@ public static IBarrel Create(string cacheDirectory)
};
}

#region Exist and Expiration Methods
#region Exist and Expiration Methods
/// <summary>
/// Checks to see if the key exists in the Barrel.
/// </summary>
Expand Down Expand Up @@ -93,9 +102,9 @@ public bool IsExpired(string key)
return DateTime.UtcNow > ent.ExpirationDate.ToUniversalTime();
}

#endregion
#endregion

#region Get Methods
#region Get Methods
/// <summary>
/// Gets all the keys that are saved in the cache
/// </summary>
Expand Down Expand Up @@ -190,9 +199,9 @@ public string GetETag(string key)
return ent.ExpirationDate;
}

#endregion
#endregion

#region Add Methods
#region Add Methods

/// <summary>
/// Adds a string netry to the barrel
Expand Down Expand Up @@ -249,9 +258,9 @@ public void Add<T>(string key, T data, TimeSpan expireIn, string eTag = null, Js
Add(key, dataJson, expireIn, eTag);
}

#endregion
#endregion

#region Empty Methods
#region Empty Methods
/// <summary>
/// Empties all expired entries that are in the Barrel.
/// Throws an exception if any deletions fail and rolls back changes.
Expand Down Expand Up @@ -279,6 +288,6 @@ public void Empty(params string[] key)
col.Delete(k);
}
}
#endregion
#endregion
}
}
2 changes: 1 addition & 1 deletion src/MonkeyCache.LiteDB/MonkeyCache.LiteDB.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="MSBuild.Sdk.Extras/1.6.61">
<Project Sdk="MSBuild.Sdk.Extras/2.0.31">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;Xamarin.WatchOS10;Xamarin.TVOS10;Xamarin.iOS10;MonoAndroid71;MonoAndroid80;MonoAndroid81;MonoAndroid90;Xamarin.Mac20;uap10.0.16299</TargetFrameworks>
Expand Down
2 changes: 1 addition & 1 deletion src/MonkeyCache.SQLite/MonkeyCache.SQLite.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="MSBuild.Sdk.Extras/1.6.61">
<Project Sdk="MSBuild.Sdk.Extras/2.0.31">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;Xamarin.WatchOS10;Xamarin.TVOS10;Xamarin.iOS10;MonoAndroid71;MonoAndroid80;MonoAndroid81;MonoAndroid90;Xamarin.Mac20;uap10.0.16299</TargetFrameworks>
Expand Down
2 changes: 1 addition & 1 deletion src/MonkeyCache.TestApp/MonkeyCache.TestApp.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
Expand Down
2 changes: 1 addition & 1 deletion src/MonkeyCache/MonkeyCache.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="MSBuild.Sdk.Extras/1.6.61">
<Project Sdk="MSBuild.Sdk.Extras/2.0.31">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;Xamarin.WatchOS10;Xamarin.TVOS10;Xamarin.iOS10;MonoAndroid71;MonoAndroid80;MonoAndroid81;MonoAndroid90;Xamarin.Mac20;uap10.0.16299</TargetFrameworks>
<Product>$(AssemblyName) ($(TargetFramework))</Product>
Expand Down

0 comments on commit 9e53326

Please sign in to comment.