V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
win7pro
V2EX  ›  PHP

我的 laravel 的 cache 变成了以秒计算缓存过期了?

  •  
  •   win7pro · 2020-03-04 21:03:12 +08:00 · 3905 次点击
    这是一个创建于 1510 天前的主题,其中的信息可能已经有所发展或是发生改变。

    遇到了让我很郁闷的事:之前一直跑的程序,用的 laravel 框架,用了缓存 cache。有段逻辑会生成一个 2 分钟的缓存,忽然发现缓存失效了,忙一晚上找原因,后来发现把缓存有效时间参数从 2 改成 120,居然成功恢复 2 分钟的缓存了……最近做过的变更是,用 composer 把 laravel/framework 升级到 v5.5.48 ,给 php-fpm 开了 opcache 和修改了 php 的可用内存,没其他变更了。

    想不明白问题在哪。

    16 条回复    2021-02-19 00:09:57 +08:00
    also24
        1
    also24  
       2020-03-04 21:11:24 +08:00   ❤️ 1
    pota
        2
    pota  
       2020-03-04 21:14:03 +08:00   ❤️ 1
    大版本升级前请查看官方文档 https://laravel.com/docs/5.8/upgrade#cache-ttl-in-seconds
    win7pro
        3
    win7pro  
    OP
       2020-03-04 21:18:21 +08:00
    @pota 但是,我一直是 5.5.x 啊
    also24
        4
    also24  
       2020-03-04 21:24:42 +08:00
    @pota #2
    奇怪的是,楼主说自己在用的是 v5.5.48

    但是我翻官方的更新记录只翻到 v5.5.46
    https://github.com/laravel/framework/blob/5.5/CHANGELOG-5.5.md
    vacker
        5
    vacker  
       2020-03-04 21:26:59 +08:00 via Android
    版本问题没跑
    pota
        6
    pota  
       2020-03-04 21:35:28 +08:00
    @win7pro #4 很奇怪 https://packagist.org/packages/laravel/framework#v5.5.48 这里确实有 5.5.48 的 tag 但是我也没翻到这个的 changelog
    also24
        7
    also24  
       2020-03-04 21:36:25 +08:00
    仔细看了一下 Commit Log,感觉锅可能在 Laravel 身上:
    https://i.loli.net/2020/03/04/roSgLR3uKyEv6sh.png

    在这个 PR 里,我们可以看到开发者是有意识到可能的后果的
    https://github.com/laravel/framework/pull/29610

    > driesvints: I'm not sure if it's wanted to make these breaking changes on a minor release? People updating their apps will see their TTL being configured wrong. Besides that supports for 5.5 ends this month.

    >GrahamCampbell: These changes are not a breaking, but a bug fix (well, every bug fix is breaking technically :P).
    >GrahamCampbell: I don't anciptiate this change will affect any other 5.5 users because 99.999% of people will be calling put and putMany. Only those who are using it as a PSR-16 instance will be using set and setMultiple, and we need to behaves correctly for those users surely?
    pota
        8
    pota  
       2020-03-04 21:36:41 +08:00
    @win7pro 抱歉 吃饭没注意看 现在应该确定是版本问题了 你可以看一下你线上框架 Cache 中底层方法有没有相关变化 = =
    pota
        9
    pota  
       2020-03-04 21:46:49 +08:00
    @pota 找到了 https://github.com/laravel/framework/commit/4c6c24f5ea4c466e505d53048224a282dba7867c 按楼上说的 应该就是此次 PR 合并导致的修改 官方居然没有进行说明
    win7pro
        10
    win7pro  
    OP
       2020-03-04 21:48:55 +08:00
    @pota 没关系:)现在改了业务代码,换成了秒解决。现在担心会不会 5.5.x 还会后续换回分钟为单位。。。
    also24
        11
    also24  
       2020-03-04 21:50:32 +08:00   ❤️ 1
    @win7pro #10
    不会,看 PR 的内容就知道,这是为了遵守 PSR-16
    https://www.php-fig.org/psr/psr-16/
    skymei
        12
    skymei  
       2020-03-05 09:11:59 +08:00
    laravel 的版本最好别随意升级,版本之间的差异比较多,很容易采坑。
    win7pro
        13
    win7pro  
    OP
       2020-03-05 09:51:29 +08:00
    @skymei 谢谢,按常理小版本升级只会改 bug 不会有这么大的逻辑变动,万万没想到
    dvaknheo
        14
    dvaknheo  
       2020-03-05 11:51:29 +08:00
    都 laravel 7 了,还用 Laravel 5.5,不怕已知安全漏洞么?
    lijialong1313
        15
    lijialong1313  
       2020-03-07 15:10:47 +08:00
    @dvaknheo 5.5 好像是 lts 版本来的,2022 年还是 2021 年过期。我就没想到居然改了这个东西还不写 changelog
    puzzle9
        16
    puzzle9  
       2021-02-19 00:09:57 +08:00
    其实 有一个解决方案 不过就是 emmmmm

    采用 now()->addMinutes(6)
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   4997 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 09:48 · PVG 17:48 · LAX 02:48 · JFK 05:48
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.