Skip to content

Conversation

@claudiamurialdo
Copy link
Collaborator

@claudiamurialdo claudiamurialdo commented Oct 20, 2025

Introduced an in-memory local cache in the Redis implementation to cache frequently accessed keys.

Issue:206738

@genexusbot
Copy link
Collaborator

Cherry pick to beta success

@claudiamurialdo claudiamurialdo temporarily deployed to kafka-integration-tests October 20, 2025 22:53 — with GitHub Actions Inactive
@claudiamurialdo claudiamurialdo temporarily deployed to external-storage-tests October 20, 2025 22:53 — with GitHub Actions Inactive
@genexusbot
Copy link
Collaborator

Cherry pick to beta success

fedeazzato
fedeazzato previously approved these changes Oct 20, 2025
Copy link
Member

@fedeazzato fedeazzato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! 💯

Comment on lines 474 to 475
if (_localCache != null)
_localCache.Set(cacheid, prefix, LocalCacheTTL(LOCAL_CACHE_PERSISTENT_KEY_TTL));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use null conditional operator to combine the null check with the actual invocation. e.g.
_localCache?.Set(cacheid, prefix, LocalCacheTTL(LOCAL_CACHE_PERSISTENT_KEY_TTL));

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly in other places it can be used as well in replacement of checking for non null, and then doing something with the field.

Comment on lines -143 to -152
Task<bool> t = RedisDatabase.KeyExpireAsync(Key(cacheid, key), expiry, flags);
t.Wait();
return t.Result;
string fullKey = Key(cacheid, key);
bool expirationSaved = RedisDatabase.KeyExpire(fullKey, expiry, flags);
if (expirationSaved)
KeyExpireLocal(fullKey);
return expirationSaved;
}

public bool KeyExists(string cacheid, string key)
{
Task<bool> t = RedisDatabase.KeyExistsAsync(Key(cacheid, key));
t.Wait();
return t.Result;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fixing this async over sync when there was a sync API available!

private void InitLocalCache()
{
#if NETCORE
if (EnvVarReader.GetEnvironmentValue(GXServices.CACHE_SERVICE, GXServices.REDIS_CACHE_SERVICE, "HYBRID", out string envVarValue) && envVarValue.Equals(true.ToString(), StringComparison.OrdinalIgnoreCase))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is extremely nitpick. Instead of true.ToString() you can use bool.TrueString which doesn't require creating a new string and is already interned.

@genexusbot
Copy link
Collaborator

Cherry pick to beta success

@claudiamurialdo claudiamurialdo temporarily deployed to kafka-integration-tests October 21, 2025 22:40 — with GitHub Actions Inactive
@claudiamurialdo claudiamurialdo temporarily deployed to external-storage-tests October 21, 2025 22:40 — with GitHub Actions Inactive
@genexusbot
Copy link
Collaborator

Cherry pick to beta success

@claudiamurialdo claudiamurialdo temporarily deployed to external-storage-tests October 22, 2025 19:26 — with GitHub Actions Inactive
@claudiamurialdo claudiamurialdo temporarily deployed to kafka-integration-tests October 22, 2025 19:26 — with GitHub Actions Inactive
@genexusbot
Copy link
Collaborator

Cherry pick to beta success

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants