-
Notifications
You must be signed in to change notification settings - Fork 285
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
[Question] Why can't spaces be used when checking if a redis key exists? #426
Comments
I think even if you could create an entry with space in DB, the underlying infra may fail since some of these translates directly to create an entry in linux kernel where space is not allowed. So IMO, this is a general restriction. |
in general is better to avoid spaces, in some places this can lead to regex wrong matching etc, in this case space it could be replaced by '=' or ':' |
Granted VRF_TABLE was a contrived example and probably shouldn't have a space in the key. My question is more generic (e.g. maybe an ACL or some policy name). AFAICT today nothing is stopping a user from creating a key with a space: The no space rule only seem to apply if the user wants to check if an entry already exists. Presumably the underlying infra would see an issue when the entry is created., Not when something checks if it already exists? |
…ors (sonic-net#426) * File system based sensors implementation for voltage and current sensors. * Added error handling for missing data in yaml file * Added test code. * Addressed review comments * Fixed missing inclusion * Fixed UT error * Fixed test case failures in other repos. * Addressed review comments * Fixed UT * Review comment * Removed empty line in diff. * Removed changes in chassis base tests
When checking if a redis entry exists the key isn't allowed to have any spaces:
https://github.com/Azure/sonic-swss-common/blob/master/common/dbconnector.cpp#L609-L613
However, that restriction doesn't seem to be enforced when creating (i.e. SET) or reading keys (i.e. KEYS). I was able to create an entry like:
Is there a technical reason for this? I guess we can use KEYS to check for existence, but the O(1) time complexity of exists is much nicer.
The text was updated successfully, but these errors were encountered: