-
Notifications
You must be signed in to change notification settings - Fork 157
Description
What happened?
I have some real world concerns regarding cachalot design compared to old johnny cache.
Using timestamps as table generation keys (instead of uuid4 sha checksum as in johhny cache) seems to be prone to errors in production deployments.
First of all Python time.time() precision on Windows seems to be 100ns. Thus if time() is called multiple times in a row, it returns the same value.
This has severe consequences.
Simple calls like Django ORM get_or_create() can be executed so fast that the timestamp will be the same for the get() and for the create() and the table key will be set in create() to the same value like for the query in the get() (I hope it is clear what I mean).
Thus further calls to ORM get() will return the old value.
What should've happened instead?
Using timestamp as table generation value (at least on Windows) seems to be insufficient. I propose to use approach similar to jmoiron's johnny cache, i.e. uuid4() + sha1 hash.
Steps to reproduce
Django 4.x
OS Windows 10
Database PostgreSQL.
[//]: # (Include host configuration: OS, Django version, database, etc.)