简体   繁体   English

Laravel 辛烷缓存不持久

[英]Laravel Octane Cache not persistent

  • Octane Version: 1.0.8辛烷值版本:1.0.8
  • Laravel Version: 8.50.0 Laravel 版本:8.50.0
  • PHP Version: 8.0 PHP 版本:8.0
  • Server & Version: Swoole 4.6.7服务器&版本:Swoole 4.6.7
  • Database Driver & Version: MySQL 8.0.25数据库驱动程序和版本:MySQL 8.0.25

Everything works as expected when using Redis for example.例如,使用Redis时,一切都按预期工作。

cache()->store('redis')->remember("test_key", now()->addMinutes(), fn() => 'test_value');

Cache::remember() method does not store the value when using Laravel Octane Cache . Cache::remember()方法在使用Laravel Octane Cache时不存储值。 (returns null) (返回空)

cache()->store('octane')->remember("test_key", now()->addMinutes(), fn() => 'test_value');

I did another tests and seems that Octane store is not persistent.我做了另一个测试,似乎Octane 存储不是持久的。 If I use put then get immediately will receive the value, if I use put then refresh the page the value will be null. This is only for Octane driver .如果我使用put然后get 会立即收到该值,如果我使用put然后刷新页面,该值将为 null。这仅适用于Octane 驱动程序 Redis store works fine. Redis 店铺工作正常。

cache()->store('octane')->put("test_key", 'test_value', now()->addMinutes());

cache()->store('octane')->get("test_key"); => returns null

Redis works as expected. Redis按预期工作。

cache()->store('redis')->put("test_key", 'test_value', now()->addMinutes());

cache()->store('redis')->get("test_key"); => returns test_value

I just ran into same issue.我刚遇到同样的问题。 It seems the "octane" cache does not work if you try to use it via console.如果您尝试通过控制台使用“octane”缓存,它似乎不起作用。 When I use it inside my controller (or anywhere where the process starts from any web request) it works fine.当我在我的 controller(或进程从任何 web 请求开始的任何地方)中使用它时,它工作正常。

I think, if you run any command of your application, the OS runs it separately.我认为,如果您运行应用程序的任何命令,操作系统会单独运行它。 In this case you can't see the soole cache (because that is under a different process) and also can't use SwooleTable (Exception: Tables may only be accessed when using the Swoole server.)在这种情况下,你看不到 soole 缓存(因为那是在不同的进程下),也不能使用 SwooleTable(例外:Tables may only be accessed when using the Swoole server.)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM