Django应用程序在Apache上托管时失败,但在Dev s上运行良好

2024-09-30 14:17:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我的基于Django的应用程序正在执行以下步骤

  1. 从XLS读取数百万条记录并将数据放入缓存

    cache.set((str(run)+“trn_data”),文件['inp_data'],3600)

  2. 缓存中存储的数据经过优化并再次存储在缓存中

    cache.set((str(run)+“tier”),tier,3600)}

  3. 数据从缓存中提取并放入数据库

    tier=cache.get((str(runid)+“tier”)

我所面临的问题是,Django-Dev服务器上的一切都正常工作,但一旦我在Apache(mod_-wsgi和Apache)上托管了应用程序,缓存就会显示为空(在步骤3)

另外,我在应用程序中使用本地Mem缓存


Tags: 文件数据djangorun应用程序cachedataapache
1条回答
网友
1楼 · 发布于 2024-09-30 14:17:41

本地内存缓存是每个进程的缓存。见警告in the docs(我的重点):

Note that each process will have its own private cache instance, which means no cross-process caching is possible. This obviously also means the local memory cache isn’t particularly memory-efficient, so it’s probably not a good choice for production environments. It’s nice for development.

对于生产,我建议您使用不同的缓存后端,例如Memcached

相关问题 更多 >