Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DB Access: OnChange cache #82

Merged
merged 4 commits into from
May 24, 2023

Conversation

sachinholla
Copy link
Contributor

@sachinholla sachinholla commented May 8, 2023

1) Introduced the OnChange cache in the DB object. Cache is maintained as map[string]db.Value, where map key is the redis key.

OnChange cache is not enabled by default. DB instance should be inited with IsEnableOnChange=true option and caching should be enabled for specific tables by calling DB.RegisterTableForOnChangeCaching(). DB.OnChangeCacheUpdate() and DB.OnChangeCacheDelete() functions should be used to refresh the cache contents.

2) Enhanced DB.GetEntry() to return value from the OnChnage cahce if the key exists in the cache. Otherwise the value will be read from redis and cache will be updated.

Part of the subscription enhancements described in the HLD sonic-net/SONiC#1287

1) Introduced the OnChange cache in the DB object. Cache is maintained
as map[string]db.Value, where map key is the redis key.

OnChange cache is not enabled by default. DB instance should be inited
with IsEnableOnChange=true option and caching should be enabled for
specific tables by calling DB.RegisterTableForOnChangeCaching().
DB.OnChangeCacheUpdate() and DB.OnChangeCacheDelete() functions should
be used to refresh the cache contents.

2) Enhanced DB.GetEntry() to return value from the OnChnage cahce if
the key exists in the cache. Otherwise the value will be read from
redis and cache will be updated.

Signed-off-by: Arun Barboza <[email protected]>
Signed-off-by: Sachin Holla <[email protected]>
Copy link

@tomek-US tomek-US left a comment

Choose a reason for hiding this comment

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

LGTM

@anand-kumar-subramanian anand-kumar-subramanian merged commit cf40f46 into sonic-net:master May 24, 2023
@sachinholla sachinholla deleted the onchange_cache branch June 18, 2023 03:42
@sachinholla sachinholla restored the onchange_cache branch June 18, 2023 03:48
@sachinholla sachinholla deleted the onchange_cache branch July 19, 2023 06:05
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