如何在 Django 中使用 redis? [英] How can I use redis with Django?

查看:23
本文介绍了如何在 Django 中使用 redis?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我听说过 redis-cache 但它究竟是如何工作的?通过以某种方式缓存 rdbms 查询,它是否用作 django 和我的 rdbms 之间的层?

I've heard of redis-cache but how exactly does it work? Is it used as a layer between django and my rdbms, by caching the rdbms queries somehow?

还是直接作为数据库使用?我对此表示怀疑,因为那个 github 页面不包含任何登录详细信息,所以没有设置.. 只是告诉您设置一些配置属性.

Or is it supposed to be used directly as the database? Which I doubt, since that github page doesn't cover any login details, no setup.. just tells you to set some config property.

推荐答案

这个 Python Redis 模块在 readme 中有明确的用法示例:http://github.com/andymccurdy/redis-py

This Python module for Redis has a clear usage example in the readme: http://github.com/andymccurdy/redis-py

Redis 被设计为 RAM 缓存.它支持键的基本 GET 和 SET 以及字典等集合的存储.您可以通过将输出存储在 Redis 中来缓存 RDBMS 查询.目标是加速您的 Django 站点.在需要速度之前不要开始使用 Redis 或任何其他缓存 - 不要过早优化.

Redis is designed to be a RAM cache. It supports basic GET and SET of keys plus the storing of collections such as dictionaries. You can cache RDBMS queries by storing their output in Redis. The goal would be to speed up your Django site. Don't start using Redis or any other cache until you need the speed - don't prematurely optimize.

这篇关于如何在 Django 中使用 redis?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆