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

storing same pointer as value for multiple different keys #47

Open
pratapan9 opened this issue Aug 16, 2018 · 1 comment
Open

storing same pointer as value for multiple different keys #47

pratapan9 opened this issue Aug 16, 2018 · 1 comment

Comments

@pratapan9
Copy link

I have a key-value pair where key is of type string and value is pointer to a struct. Suppose theres a single struct object.. Can I safely store say three different keys and all their value being pointer to the same single struct.. ?

@paskal
Copy link
Contributor

paskal commented May 9, 2020

Values are stored as-is and changing the mutable value will change all its references. You can store multiple pointers to the same object, but there is no magic in this cache that would prevent you from changing this object elsewhere and then observing this change on value, stored in a cache.

However, if you won't change the object your pointing to in your code, you can safely put it to cache and delete as many of these entries as you want, it still will be available as long as you have at least one pointer to it.

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

No branches or pull requests

2 participants