-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #196 from code4romania/features/memory-cache
Brought back memory cache for elections older than 2024
- Loading branch information
Showing
10 changed files
with
144 additions
and
34 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
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
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,44 @@ | ||
using ElectionResults.Core.Entities; | ||
|
||
namespace ElectionResults.Core.Repositories | ||
{ | ||
public class MemoryCache | ||
{ | ||
public static readonly CacheSettings Parties = new CacheSettings("all_parties", 60*24); | ||
|
||
public static readonly CacheSettings Ballots = new CacheSettings("all_ballots", 60*24); | ||
|
||
public static readonly CacheSettings Elections = new CacheSettings("all_elections", 60*24); | ||
|
||
public static readonly CacheSettings Counties = new CacheSettings("all_counties", 60*24); | ||
|
||
public static readonly CacheSettings Localities = new CacheSettings("all_localities", 60*24); | ||
|
||
public static readonly CacheSettings Locality = new CacheSettings("locality", 60*24); | ||
|
||
public static readonly CacheSettings County = new CacheSettings("county", 60*24); | ||
|
||
public static readonly CacheSettings Countries = new CacheSettings("all_countries", 60*24); | ||
|
||
public const string NationalTurnout = "national-total"; | ||
public const string DiasporaTurnout = "diaspora-total"; | ||
|
||
public static string CreateWinnersKey(int ballotId, int? countyId, ElectionDivision division) | ||
{ | ||
return $"winner-{ballotId}-{countyId}-{division}"; | ||
} | ||
} | ||
|
||
public class CacheSettings | ||
{ | ||
public CacheSettings(string key, int durationInMinutes) | ||
{ | ||
Key = key; | ||
Minutes = durationInMinutes; | ||
} | ||
|
||
public string Key { get; set; } | ||
|
||
public int Minutes { 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
Oops, something went wrong.