mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-15 15:55:54 +01:00
Added DeleteCacheKey method to TMVCCacheController (#731)
Deletes the specified key(s) from the Redis cache. Pattern matching can be used to delete multiple keys
This commit is contained in:
parent
cc5789d56e
commit
0ceb7180fa
@ -80,6 +80,10 @@ type
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
procedure SetCacheKey(const AKey: string);
|
procedure SetCacheKey(const AKey: string);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Deletes the specified key(s) from the redis cache. Pattern matching can be used to delete multiple keys
|
||||||
|
/// </summary>
|
||||||
|
procedure DeleteCacheKey(const AKey: string = '');
|
||||||
|
/// <summary>
|
||||||
/// Returns true if the cache is available and automatically fills
|
/// Returns true if the cache is available and automatically fills
|
||||||
/// the response using the cache contents
|
/// the response using the cache contents
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -93,6 +97,7 @@ type
|
|||||||
/// retrived from cache
|
/// retrived from cache
|
||||||
/// </summary>
|
/// </summary>
|
||||||
property ExposeCache: Boolean read FExposeCache write SetExposeCache;
|
property ExposeCache: Boolean read FExposeCache write SetExposeCache;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -258,4 +263,22 @@ begin
|
|||||||
FExposeCache := AValue;
|
FExposeCache := AValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TMVCCacheController.DeleteCacheKey(const AKey: string = '');
|
||||||
|
var
|
||||||
|
AKeys: TArray<string>;
|
||||||
|
ARedis: IRedisClient;
|
||||||
|
begin
|
||||||
|
ARedis := RedisClient;
|
||||||
|
if AKey <> '' then
|
||||||
|
begin
|
||||||
|
AKeys := ARedis.KEYS(AKey).ToArray;
|
||||||
|
ARedis.DEL(AKeys);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
CheckCacheKey;
|
||||||
|
ARedis.DEL(FCurrentCacheKey);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user