-
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.
Merge branch 'feature_LWDEV-7546-Improve-caching-for-asset-pairs' int…
…o dev
- Loading branch information
Showing
21 changed files
with
348 additions
and
289 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 was deleted.
Oops, something went wrong.
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
23 changes: 23 additions & 0 deletions
23
client/Lykke.Service.Assets.Client/Cache/ExpiringDictionaryCache.cs
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,23 @@ | ||
using System; | ||
using Lykke.Service.Assets.Client.Updaters; | ||
|
||
namespace Lykke.Service.Assets.Client.Cache | ||
{ | ||
/// <summary> | ||
/// Expiring dictionary cache where the cache entry expires after given time. | ||
/// </summary> | ||
/// <typeparam name="T">the type of cached item</typeparam> | ||
internal sealed class ExpiringDictionaryCache<T> : DictionaryCache<T> | ||
where T : ICacheItem | ||
{ | ||
/// <summary> | ||
/// Create a new expiring dictionary cache. | ||
/// </summary> | ||
/// <param name="expirationTime">expiration time</param> | ||
/// <param name="updater">item updater</param> | ||
public ExpiringDictionaryCache(TimeSpan expirationTime, IUpdater<T> updater) | ||
: base(updater, expirationTime) | ||
{ | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,7 +1,13 @@ | ||
namespace Lykke.Service.Assets.Client.Cache | ||
{ | ||
public interface ICacheItem | ||
/// <summary> | ||
/// Cache item {T} in a <see cref="IDictionaryCache{T}"/>. | ||
/// </summary> | ||
internal interface ICacheItem | ||
{ | ||
/// <summary> | ||
/// The id of the entry | ||
/// </summary> | ||
string Id { get; } | ||
} | ||
} |
9 changes: 0 additions & 9 deletions
9
client/Lykke.Service.Assets.Client/Cache/IDateTimeProvider .cs
This file was deleted.
Oops, something went wrong.
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
37 changes: 37 additions & 0 deletions
37
client/Lykke.Service.Assets.Client/Cache/RefreshingDictionaryCache.cs
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,37 @@ | ||
using System; | ||
using Common; | ||
using Common.Log; | ||
using Lykke.Service.Assets.Client.Updaters; | ||
|
||
namespace Lykke.Service.Assets.Client.Cache | ||
{ | ||
/// <summary> | ||
/// A dictionary cache that refreshes/synchronizes in the background. | ||
/// </summary> | ||
/// <typeparam name="T">the type of cached item</typeparam> | ||
internal sealed class RefreshingDictionaryCache<T> : DictionaryCache<T>, IDisposable | ||
where T : ICacheItem | ||
{ | ||
private readonly TimerTrigger _trigger; | ||
|
||
/// <summary> | ||
/// Creates a new refreshing dictionary cache. | ||
/// </summary> | ||
/// <param name="refreshTime">the refresh time</param> | ||
/// <param name="updater">the item updater</param> | ||
/// <param name="log">the lykke log</param> | ||
public RefreshingDictionaryCache(TimeSpan refreshTime, IUpdater<T> updater, ILog log) | ||
: base(updater, refreshTime.Add(refreshTime)) | ||
{ | ||
_trigger = new TimerTrigger(nameof(AssetsService), refreshTime, log, | ||
async (x, y, token) => await Reset(token)); | ||
_trigger.Start(); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public void Dispose() | ||
{ | ||
_trigger?.Dispose(); | ||
} | ||
} | ||
} |
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.