【问题标题】:How to cache closures in php如何在php中缓存闭包
【发布时间】:2019-11-11 10:16:24
【问题描述】:

我想缓存一个也有闭包的数组。

我试过了:

  • serialize() - 不能序列化闭包
  • json_encode() - 用空值替换闭包
  • base64_encode() - 不接受数组

缓存包含闭包的数组还需要做什么?

【问题讨论】:

标签: php arrays caching closures callable


【解决方案1】:

PHP 中的闭包不能“从盒子里”序列化,因此数组也带有闭包。您只能使用 3rd 方方式/库来达到此目的。 在这里讨论:Serializing anonymous functions in php

【讨论】:

    猜你喜欢
    • 2011-09-22
    • 2011-10-26
    • 2020-10-06
    • 2011-10-17
    • 2023-03-17
    • 2010-12-16
    • 2010-12-06
    • 2020-07-15
    • 2020-04-28
    相关资源
    最近更新 更多