Join GitHub today
Implement aliases in cache #911
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:
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.