You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
noripyt#135
Have the table key generation look for a "CACHE_KEY" configuration in the Django DATABASES configs.
If a "CACHE_KEY" value is found, then we use that instead of the "db_alias".
This allows us to synch Master and Replicas to use the same key namespace to prevent "double-caching" and the need to invalidate 2 cache entries upon an update.
The Django configuration would look like:
DATABASES = {
'master': {
'CACHE_KEY': 'WE_ARE_ONE',
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': DB_NAME,
'USER': DB_USER,
'PASSWORD': DB_PASSWORD,
'HOST': DB_HOST,
'PORT': DB_PORT,
'OPTIONS': {
'client_encoding': "UTF8"
}
},
'replica' : {
'CACHE_KEY': 'WE_ARE_ONE',
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': DB_NAME,
'USER': DB_USER,
'PASSWORD': DB_PASSWORD,
'HOST': DB_HOST,
'PORT': DB_PORT,
'OPTIONS': {
'client_encoding': "UTF8"
}
}
}
If we have both a master and replica database configured, cachalot uses separate database aliases as part of the cache key.
This results in the same "data"being cached twice.
It also makes cache invalidation trickier as we have to invalidate multiple cached entries.
The text was updated successfully, but these errors were encountered: