forked from dotnetcore/EasyCaching
-
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.
- Loading branch information
1 parent
bf31532
commit f2b3f3a
Showing
5 changed files
with
669 additions
and
0 deletions.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
src/EasyCaching.Core/Diagnostics/EasyCachingDiagnosticListenerExtensions.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,76 @@ | ||
namespace EasyCaching.Core.Diagnostics | ||
{ | ||
using System.Diagnostics; | ||
|
||
public static class EasyCachingDiagnosticListenerExtensions | ||
{ | ||
/// <summary> | ||
/// The name of the diagnostic listener. | ||
/// </summary> | ||
public const string DiagnosticListenerName = "EasyCachingDiagnosticListener"; | ||
|
||
public const string EasyCachingSetCache = nameof(WriteSetCache); | ||
public const string EasyCachingExistsCache = nameof(WriteExistsCache); | ||
public const string EasyCachingFlushCache = nameof(WriteFlushCache); | ||
public const string EasyCachingRemoveCache = nameof(WriteRemoveCache); | ||
public const string EasyCachingGetCache = nameof(WriteGetCache); | ||
public const string EasyCachingGetCount = nameof(WriteGetCount); | ||
public const string EasyCachingSetAll = nameof(WriteSetAll); | ||
|
||
public static void WriteSetCache(this DiagnosticListener @this, SetCacheEventData eventData) | ||
{ | ||
if (@this.IsEnabled(EasyCachingSetCache)) | ||
{ | ||
@this.Write(EasyCachingSetCache, eventData); | ||
} | ||
} | ||
|
||
public static void WriteRemoveCache(this DiagnosticListener @this, RemoveCacheEventData eventData) | ||
{ | ||
if (@this.IsEnabled(EasyCachingRemoveCache)) | ||
{ | ||
@this.Write(EasyCachingRemoveCache, eventData); | ||
} | ||
} | ||
|
||
public static void WriteGetCache(this DiagnosticListener @this, GetCacheEventData eventData) | ||
{ | ||
if (@this.IsEnabled(EasyCachingGetCache)) | ||
{ | ||
@this.Write(EasyCachingGetCache, eventData); | ||
} | ||
} | ||
|
||
public static void WriteSetAll(this DiagnosticListener @this, SetAllEventData eventData) | ||
{ | ||
if (@this.IsEnabled(EasyCachingSetAll)) | ||
{ | ||
@this.Write(EasyCachingSetAll, eventData); | ||
} | ||
} | ||
|
||
public static void WriteGetCount(this DiagnosticListener @this, GetCountEventData eventData) | ||
{ | ||
if (@this.IsEnabled(EasyCachingGetCount)) | ||
{ | ||
@this.Write(EasyCachingGetCount, eventData); | ||
} | ||
} | ||
|
||
public static void WriteExistsCache(this DiagnosticListener @this, ExistsCacheEventData eventData) | ||
{ | ||
if (@this.IsEnabled(EasyCachingExistsCache)) | ||
{ | ||
@this.Write(EasyCachingExistsCache, eventData); | ||
} | ||
} | ||
|
||
public static void WriteFlushCache(this DiagnosticListener @this, EventData eventData) | ||
{ | ||
if (@this.IsEnabled(EasyCachingFlushCache)) | ||
{ | ||
@this.Write(EasyCachingFlushCache, eventData); | ||
} | ||
} | ||
} | ||
} |
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,101 @@ | ||
namespace EasyCaching.Core.Diagnostics | ||
{ | ||
using System; | ||
|
||
public class EventData | ||
{ | ||
public EventData(string cacheType, string name, string operation) | ||
{ | ||
this.CacheType = cacheType; | ||
this.Name = name; | ||
this.Operation = operation; | ||
} | ||
|
||
public string CacheType { get; set; } | ||
|
||
public string Name { get; set; } | ||
|
||
public string Operation { get; set; } | ||
} | ||
|
||
public class RemoveCacheEventData : EventData | ||
{ | ||
public RemoveCacheEventData(string cacheType, string name, string operation, string[] cacheKeys) | ||
: base(cacheType, name, operation) | ||
{ | ||
this.CacheKeys = cacheKeys; | ||
} | ||
|
||
public string[] CacheKeys { get; set; } | ||
} | ||
|
||
public class GetCacheEventData : EventData | ||
{ | ||
public GetCacheEventData(string cacheType, string name, string operation, string[] cacheKeys) | ||
: base(cacheType, name, operation) | ||
{ | ||
this.CacheKeys = cacheKeys; | ||
} | ||
|
||
public string[] CacheKeys { get; set; } | ||
} | ||
|
||
public class GetCountEventData : EventData | ||
{ | ||
public GetCountEventData(string cacheType, string name, string operation, string prefix, long count) | ||
: base(cacheType, name, operation) | ||
{ | ||
this.Prefix = prefix; | ||
this.Count = count; | ||
} | ||
|
||
public string Prefix { get; set; } | ||
|
||
public long Count { get; set; } | ||
} | ||
|
||
public class SetCacheEventData : EventData | ||
{ | ||
public SetCacheEventData(string cacheType, string name, string operation, string cacheKey, object cacheValue, TimeSpan expiration) | ||
: base(cacheType, name, operation) | ||
{ | ||
this.CacheKey = cacheKey; | ||
this.CacheValue = cacheValue; | ||
this.Expiration = expiration; | ||
} | ||
|
||
public string CacheKey { get; set; } | ||
|
||
public object CacheValue { get; set; } | ||
|
||
public TimeSpan Expiration { get; set; } | ||
} | ||
|
||
public class SetAllEventData : EventData | ||
{ | ||
public SetAllEventData(string cacheType, string name, string operation, object values, TimeSpan expiration) | ||
: base(cacheType, name, operation) | ||
{ | ||
this.Values = values; | ||
this.Expiration = expiration; | ||
} | ||
|
||
public object Values { get; set; } | ||
|
||
public TimeSpan Expiration { get; set; } | ||
} | ||
|
||
public class ExistsCacheEventData : EventData | ||
{ | ||
public ExistsCacheEventData(string cacheType, string name, string operation, string cacheKey, bool flag) | ||
: base(cacheType, name, operation) | ||
{ | ||
this.CacheKey = cacheKey; | ||
this.Flag = flag; | ||
} | ||
|
||
public string CacheKey { get; set; } | ||
|
||
public bool Flag { 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.