为什么 storage 里面要加入缓存 cache

今天看文档, storage里面可以加入缓存cache

An absolute must for performance is to use a cached adapter. You will need an additional package for this:

  • CachedAdapter: league/flysystem-cached-adapter ~1.0
's3' => [
    'driver' => 's3',

    // Other Disk Options...

    'cache' => [
        'store' => 'memcached',
        'expire' => 600,
        'prefix' => 'cache-prefix',
    ],
],

不明白为什么文件系统要加入缓存.
如果用的是云存储, 应该读取是直接从云端直接传给用户, 也不用经过服务器.
如果是存储到本地, 本来已经是文件了, 难道要写入内存来进行缓存吗? 那这样多读取几张图片内存就不够了啊.

《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
最佳答案

查到了一篇关于 league/flysystem-cached-adapter 的介绍, 大概意思就是用来缓存meta-data来加速io读取效率

https://flysystem.thephpleague.com/v1/docs...

4年前 评论
讨论数量: 3

这个缓存并不是缓存文件内容,具体我也不懂

这图是他的缓存数据
file

4年前 评论

记得以前用Storage::url(),也就循环几十遍。

电脑cpu很渣的,加载要1s+

后面受不了,封装了个ossUrl()函数,手动拼装返回路径。
当然也可以用缓存来解决我这个问题的。

4年前 评论

查到了一篇关于 league/flysystem-cached-adapter 的介绍, 大概意思就是用来缓存meta-data来加速io读取效率

https://flysystem.thephpleague.com/v1/docs...

4年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!