-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated serializers to deep compare objects
- Loading branch information
1 parent
87e9c69
commit 8780b18
Showing
11 changed files
with
214 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace Cute.Lib.Cache; | ||
|
||
public class HttpResponseFileCache | ||
{ | ||
private readonly string _tempPath = Path.Combine(Path.GetTempPath(), "cute"); | ||
|
||
public async Task<T?> Get<T>(string fileBaseName, Func<Task<T>> createObject) | ||
{ | ||
var filename = Path.Combine(_tempPath, $"{fileBaseName}.json"); | ||
|
||
Directory.CreateDirectory(_tempPath); | ||
|
||
if (File.Exists(filename)) | ||
{ | ||
return JsonConvert.DeserializeObject<T>(await File.ReadAllTextAsync(filename)); | ||
} | ||
|
||
var newObject = await createObject(); | ||
|
||
await File.WriteAllTextAsync(filename, JsonConvert.SerializeObject(newObject)); | ||
|
||
return newObject; | ||
} | ||
} | ||
|
||
public class HttpResponseCacheEntry | ||
{ | ||
public string RequestUri { get; set; } = default!; | ||
|
||
public object? ResponseContent { get; set; } = default!; | ||
|
||
public Dictionary<string, string?> ResponseContentHeaders { get; set; } = []; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.