Skip to content

DB Access: OnChange cache#82

Merged
anand-kumar-subramanian merged 4 commits intosonic-net:masterfrom
sachinholla:onchange_cache
May 24, 2023
Merged

DB Access: OnChange cache#82
anand-kumar-subramanian merged 4 commits intosonic-net:masterfrom
sachinholla:onchange_cache

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