可能重复:
Django cache.set() causing duplicate key errorDjango缓存导致数据库中重复的键错误?
我就遇到了这个问题,使用Django核心的数据库缓存:
ERROR: duplicate key value violates unique constraint "cache_pkey"
STATEMENT: INSERT INTO "cache" (cache_key, value, expires) VALUES (E':1:cms-menu_nodes_en-us_1', E'gAJdcQEoY21lbnVzLmJhc2UKTmF2aW
LOG: server process (PID 8453) was terminated by signal 9: Killed
LOG: terminating any other active server processes
LOG: all server processes terminated; reinitializing
FATAL: could not create shared memory segment: Cannot allocate memory
DETAIL: Failed system call was shmget(key=5432001, size=29278208, 03600).
我在表中果然一看,有一个输入密钥':1:cms-menu_nodes_en-us_1'。我发现了一个类似的问题here,但无法准确理解问题所在。
任何人有任何想法或建议?听起来像Django核心中的错误,因为如果存在密钥,它应该更新记录。
编辑:我应该澄清,数据库是PostgreSQL 8.4.7。感谢lazerscience。
编辑@杰克中号:我一直没能复制这一错误,但相信该代码是在django.core.cache.backends.db.DatabaseCache
在一个名为set()
方法调用_base_set()
。
你试过什么数据库后端?与其他人一起尝试... –
将此条目添加到缓存的代码是什么? –