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

Implement aliases in cache #911

jsabater opened this Issue Jan 25, 2019 · 1 comment


None yet
2 participants
Copy link

jsabater commented Jan 25, 2019

As per the discussion on this thread on the forum, some model classes may have more than one unique id (e.g. the locator of a flight), so you may find yourself in the need to implement services to search by any of such ids. When caching the results via Zato's Cache API, allowing cache keys to have aliases may be a nice feature to have. One way to set a cache entry with aliases would be:

self.cache.set('key', 'value', alias=['alias1', 'alias2'])

Meaning there would be three pointers to the same data, which could be retrieved through any of the following calls:


The cache system would have to take into consideration dealing with aliases when something happens to the key, such as expiring, being deleted, being re-created or updated so that no ghost aliases are left behind.

Finally, when dealing with calls such as get_by_prefix, a limit parameter would come in handy, as it is expected that the developer knows the amount of alises, hence can help the search by narrowing it down to a number of occurrences.

dsuch added a commit that referenced this issue Jan 25, 2019


This comment has been minimized.

Copy link

dsuch commented Jan 25, 2019

The limit parameter is done, you can use it with any if get/set/delete/expire_by_* operation, e.g.

out = self.cache.default.get_by_prefix('my-prefix', limit=3)

Aliases are a bit more involved and will be added at a later time.

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