Skip to content

Commit

Permalink
Merge pull request #305 from HeDo88TH/master
Browse files Browse the repository at this point in the history
Fixed delete bug edge case
  • Loading branch information
HeDo88TH authored Nov 26, 2024
2 parents d578601 + 4879f47 commit dc20a11
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Registry.Ports/ICacheManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public interface ICacheManager

void Set(string seed, string category, string data, params object[] parameters);

Task Clear(string seed, string category = null);
void Clear(string seed, string category = null);
void Remove(string seed, string category, params object[] parameters);

bool IsRegistered(string seed);
Expand Down
6 changes: 3 additions & 3 deletions Registry.Web/Registry.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<UserSecretsId>4e006835-31cb-47c5-9dfe-7b73e210db92</UserSecretsId>
<SpaRoot>ClientApp\</SpaRoot>
<DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes>
<AssemblyVersion>1.1.9</AssemblyVersion>
<FileVersion>1.1.9</FileVersion>
<AssemblyVersion>1.1.10</AssemblyVersion>
<FileVersion>1.1.10</FileVersion>
<Version>1.1.7</Version>
<Platforms>AnyCPU;x64</Platforms>
<PackageVersion>1.1.9</PackageVersion>
<PackageVersion>1.1.10</PackageVersion>
<Configurations>Debug;Release;DebugEf</Configurations>
<DdbVersion>1.0.12</DdbVersion>
</PropertyGroup>
Expand Down
19 changes: 10 additions & 9 deletions Registry.Web/Services/Managers/CacheManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,16 @@ public void Set(string seed, string category, string data, params object[] param
_cache.Set(key, data, policy);
}

public Task Clear(string seed, string category = null)
public void Clear(string seed, string category = null)
{
return Task.Run(() =>
{
var k = category != null ? MakeKey(seed, category, null) : seed;
var keys = _cache.Where(o => o.Key.StartsWith(k)).Select(o => o.Key).ToArray();

foreach (var key in keys)
_cache.Remove(key);
});
ArgumentNullException.ThrowIfNull(seed);
var k = category != null ? MakeKey(seed, category, null) : seed;

var keys = _cache.Where(o => o.Key != null && o.Key.StartsWith(k))
.Select(o => o.Key).ToArray();

foreach (var key in keys)
_cache.Remove(key);

}
}
4 changes: 2 additions & 2 deletions Registry.Web/Services/Managers/ObjectsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,8 @@ public async Task Delete(string orgSlug, string dsSlug, string path)

_fs.Delete(objLocalPath);

await _cacheManager.Clear(MagicStrings.ThumbnailCacheSeed, obj.Hash);
await _cacheManager.Clear(MagicStrings.TileCacheSeed, obj.Hash);
_cacheManager.Clear(MagicStrings.ThumbnailCacheSeed, obj.Hash);
_cacheManager.Clear(MagicStrings.TileCacheSeed, obj.Hash);
}
catch (Exception ex)
{
Expand Down

0 comments on commit dc20a11

Please sign in to comment.