《Django 5 By Example》阅读笔记:p614-p644

《Django 5 By Example》学习第 22 天,p614-p644 总结,总计 31 页。

一、技术总结

1.功能: students 应用

2.缓存

Django自带的缓存有:

(1)backends.memcached.PyMemcacheCache

(2) backends.redis.RedisCache

(3)backends.db.DatabaseCache

(4)backends.filebased.FileBasedCache

(5)backends.locmem.LocMemCache

(6)backends.dummy.DummyCache

For optimal performance, use a memory-based cache backend like Memcached or Redis,

since accessing memory is faster than accessing data from databases of files(为了获得最佳性能,请使用基于内存的缓存后端,如Memcached或Redis,因为访问内存比从数据库或文件访问数据要快)

其实我很想知道既然 Memcached 和 Redis 都是基于内存,那么该怎么选择呢?很遗憾,作者选择了 Memcached(Memcached is a popular high-performance, memory-based cache server. We are going to use Memcached and the PyMemcacheCache Memcached backend.),但是为什么没有选择 Redis呢(当然,作者第 7 章也使用了 Redis 进行缓存)?作者没有进行比较说明。

Python中使用的 Memcached 客户端是pymemcache 包。

3.memcached

(1)docker compose 部署

python 复制代码
 memcached:

   image: memcached:latest
    container_name: memcached
    ports:
      - "11211:11211"
    restart: always
    command: memcached -m 64 -vv

作者使用的是 docker run 进行部署,每次看到这个,我就心生怨念,在实际业务中是不可能这样启动容器的,因为这容器多了之后非常不好管理。这里补充一下使用 docker compose 的方式启动容器。

二、英语总结(生词:1)

1.entail

(1)entail: en-("make") + taile("legal limitation")

vt. to involve sth(涉及,牵涉)。p628, Processing HTTP requests to your web application usually entails database access, data manipulation, and template rendering。

2.granularity

(1)granularity: granum("grain(颗粒,谷粒), seed") + -arity(a suffix that forms nouns)

u. refers to the state or quality of being made up of small, distinct parts---like grains。p628, Django includes a robust cache system that allows you to cache data with different levels of granularity(Django包含一个强大的缓存系统,允许你缓存不同颗粒度级别的数据)。

3.allot

(1)allot: ad-("to") + loter("lot")

vt. to give a share of sth for a particular purpose(分配,分派)。p629, Memcached runs in memory, and it is allotted a specified amount of RAM。

三、其它

完结,撒花。明天出读后感。

四、参考资料

1. 编程

(1) Antonio Melé,《Django 5 By Example》:https://book.douban.com/subject/37007362/

2. 英语

(1) Etymology Dictionary:https://www.etymonline.com

(2) Cambridge Dictionary:https://dictionary.cambridge.org

欢迎搜索及关注:编程人(a_codists)

相关推荐
扯淡的闲人8 分钟前
多语言编码Agent解决方案(2)-后端服务实现
开发语言·python·深度学习
蒋星熠12 分钟前
深度学习实战指南:从神经网络基础到模型优化的完整攻略
人工智能·python·深度学习·神经网络·机器学习·卷积神经网络·transformer
万粉变现经纪人42 分钟前
如何解决pip安装报错ModuleNotFoundError: No module named ‘cuml’问题
python·scrapy·beautifulsoup·pandas·ai编程·pip·scipy
IT学长编程44 分钟前
计算机毕业设计 基于Hadoop豆瓣电影数据可视化分析设计与实现 Python 大数据毕业设计 Hadoop毕业设计选题【附源码+文档报告+安装调试
大数据·hadoop·python·django·毕业设计·毕业论文·豆瓣电影数据可视化分析
java1234_小锋1 小时前
Scikit-learn Python机器学习 - 分类算法 - K-近邻(KNN)算法
python·算法·机器学习
大翻哥哥1 小时前
Python上下文管理器进阶指南:不仅仅是with语句
前端·javascript·python
QiZhang | UESTC1 小时前
JAVA算法练习题day11
java·开发语言·python·算法·hot100
PyHaVolask2 小时前
Python进阶教程:随机数、正则表达式与异常处理
python·正则表达式·异常处理·随机数生成
折翼的恶魔2 小时前
数据分析:合并二
python·数据分析·pandas
三体世界4 小时前
测试用例全解析:从入门到精通(1)
linux·c语言·c++·python·功能测试·测试用例·测试覆盖率