Closed kilzdavi closed 9 months ago
Hi kilzdavi! Get
and Put
methods are called twice in a single GetSecretString
invocation when you fetch the secret from caching client for the first time. This is an expected behavior. Following is the break down of calls. Please notice that there are actually two caches in the memory.
secretId
→ secretCacheItem
: Contains a DescribeSecretResponse
object, which records a mapping from versionIds to stages
versionId
→ secretCacheVersion
: Contains a GetSecretValueResponse
object, which in turn stores the actual secret string
Both DescribeSecretResponse
and GetSecretValueResponse
are processed through the Put
method for caching, and the Get
method for retrieval. And hence you notice twice invocation of them in a single GetSecretString
operation.
If you are tracking Get
and Put
calls from the hook, please take a look here. They get called in GetResult and SetResult. Both SecretCacheItem and SecretCacheVersion extend SecretCacheObject.
When using the cache hook with the caching client, Get() and Put() methods are called twice called twice when obtaining values using GetSecretString().
To Reproduce
Expected behavior Either Get or Put to write to console a single time.
Result Get or Put methods are called twice.
Environment .NET 6, MacOS 13.5.2, Rider IDE.
Additional context
I am using the caching client through dependency injection.
I was tracing the call stack and GetSecretString is calling GetSecretValue(). GetSecretValue() calls GetResult() [Triggers cachehook] and GetSecretValueAsync() GetSecretValueAsync() again calls GetSecretValue() and GetResult()[Triggering cache hook]
I hope this makes sense