Symfony Cache报错Cache key ‘xxx:xxx’ contains reserved characters解决办法

今天在使用Symfony Cache时遇到一个报错:Symfony\Component\Cache\Exception\InvalidArgumentException: Cache key "xxx:xxx" contains reserved characters "{}()/\@:",经过排查发现我的缓存key带有冒号。

根据报错信息找源头,文件vendor/symfony/cache/Traits/AbstractAdapterTrait.php第396行有如下代码:

\assert('' !== CacheItem::validateKey($key));

这里有一个断言,会根据CacheItem::RESERVED_CHARACTERS(值为{}()/\@:)来判断缓存key是否合法。

通过PHP官方文档对assert的说明,发现PHP7以上版本有如下配置:

指令 默认值 可能值
zend.assertions 1 1:生成并执行代码(开发模式)
0:生成代码但在运行时跳转
-1:生成代码但在运行时跳转(生产模式)
assert.exception 0 1:断言失败时抛出,抛出提供给 exception 的对象,或未提供 exception 时抛出新的 AssertionError 对象
0:如上所述使用/生成 Throwable,但仅仅是基于该对象生成警告而不是抛出(与 PHP 5 行为兼容)

所以解决办法有两种:

  • 修改php.ini配置,将zend.assertions的值设置为0或-1

  • 去除缓存key中的特殊符号

评论

  1. 3 月前
    2024-2-29 13:20:12

    Your blog post had me hooked from the first sentence.

  2. 1 月前
    2024-4-06 0:30:03

    You’re so awesome! I don’t believe I have read a single thing like that before. So great to find someone with some original thoughts on this topic. Really.. thank you for starting this up. This website is something that is needed on the internet, someone with a little originality!

  3. 1 月前
    2024-4-06 16:51:09

    For the reason that the admin of this site is working, no uncertainty very quickly it will be renowned, due to its quality contents.

  4. 1 月前
    2024-4-07 15:01:37

    This is really interesting, You’re a very skilled blogger. I’ve joined your feed and look forward to seeking more of your magnificent post. Also, I’ve shared your site in my social networks!

  5. 1 月前
    2024-4-09 4:25:11

    I just like the helpful information you provide in your articles

  6. 1 月前
    2024-4-09 17:12:57

    For the reason that the admin of this site is working, no uncertainty very quickly it will be renowned, due to its quality contents.

  7. 1 月前
    2024-4-09 21:22:01

    There is definately a lot to find out about this subject. I like all the points you made

  8. 1 月前
    2024-4-16 9:35:15

    There is definately a lot to find out about this subject. I like all the points you made

  9. 1 月前
    2024-4-18 22:27:51

    Awesome! Its genuinely remarkable post, I have got much clear idea regarding from this post

  10. 4 周前
    2024-4-21 7:20:46

    This is my first time pay a quick visit at here and i am really happy to read everthing at one place

  11. 4 周前
    2024-4-23 1:03:53

    Great information shared.. really enjoyed reading this post thank you author for sharing this post .. appreciated

  12. 4 周前
    2024-4-23 16:02:04

    I appreciate you sharing this blog post. Thanks Again. Cool.

  13. 4 周前
    2024-4-23 22:37:58

    Awesome! Its genuinely remarkable post, I have got much clear idea regarding from this post

  14. 4 周前
    2024-4-24 0:47:51

    This is really interesting, You’re a very skilled blogger. I’ve joined your feed and look forward to seeking more of your magnificent post. Also, I’ve shared your site in my social networks!

  15. 4 周前
    2024-4-24 20:40:26

    Very well presented. Every quote was awesome and thanks for sharing the content. Keep sharing and keep motivating others.

  16. 4 周前
    2024-4-25 3:33:57

    I appreciate you sharing this blog post. Thanks Again. Cool.

  17. 4 周前
    2024-4-25 10:07:34

    Very well presented. Every quote was awesome and thanks for sharing the content. Keep sharing and keep motivating others.

  18. 3 周前
    2024-4-29 3:24:04

    Awesome! Its genuinely remarkable post, I have got much clear idea regarding from this post

  19. 3 周前
    2024-4-29 3:46:01

    This is really interesting, You’re a very skilled blogger. I’ve joined your feed and look forward to seeking more of your magnificent post. Also, I’ve shared your site in my social networks!

  20. 3 周前
    2024-4-29 4:18:09

    Hi there to all, for the reason that I am genuinely keen of reading this website’s post to be updated on a regular basis. It carries pleasant stuff.

  21. 3 周前
    2024-4-29 5:01:43

    Good post! We will be linking to this particularly great post on our site. Keep up the great writing

  22. 3 周前
    2024-4-29 7:13:35

    I like the efforts you have put in this, regards for all the great content.

  23. 3 周前
    2024-4-29 7:45:20

    Very well presented. Every quote was awesome and thanks for sharing the content. Keep sharing and keep motivating others.

  24. 3 周前
    2024-4-29 9:50:00

    I’m often to blogging and i really appreciate your content. The article has actually peaks my interest. I’m going to bookmark your web site and maintain checking for brand spanking new information.

  25. 3 周前
    2024-4-29 18:29:31

    Great information shared.. really enjoyed reading this post thank you author for sharing this post .. appreciated

  26. 3 周前
    2024-4-29 19:19:34

    I just like the helpful information you provide in your articles

  27. 3 周前
    2024-4-29 19:25:32

    Hi there to all, for the reason that I am genuinely keen of reading this website’s post to be updated on a regular basis. It carries pleasant stuff.

  28. 3 周前
    2024-4-29 20:00:55

    I’m often to blogging and i really appreciate your content. The article has actually peaks my interest. I’m going to bookmark your web site and maintain checking for brand spanking new information.

  29. Good post! We will be linking to this particularly great post on our site. Keep up the great writing

  30. I just like the helpful information you provide in your articles

  31. 3 周前
    2024-4-29 22:05:45

    This is really interesting, You’re a very skilled blogger. I’ve joined your feed and look forward to seeking more of your magnificent post. Also, I’ve shared your site in my social networks!

  32. 3 周前
    2024-4-29 22:46:22

    Pretty! This has been a really wonderful post. Many thanks for providing these details.

  33. 3 周前
    2024-4-29 23:04:19

    Hi there to all, for the reason that I am genuinely keen of reading this website’s post to be updated on a regular basis. It carries pleasant stuff.

  34. 3 周前
    2024-4-29 23:17:49

    naturally like your web site however you need to take a look at the spelling on several of your posts. A number of them are rife with spelling problems and I find it very bothersome to tell the truth on the other hand I will surely come again again.

  35. 3 周前
    2024-4-30 0:10:07

    For the reason that the admin of this site is working, no uncertainty very quickly it will be renowned, due to its quality contents.

  36. I appreciate you sharing this blog post. Thanks Again. Cool.

  37. 3 周前
    2024-4-30 2:28:19

    I’m often to blogging and i really appreciate your content. The article has actually peaks my interest. I’m going to bookmark your web site and maintain checking for brand spanking new information.

  38. 3 周前
    2024-4-30 2:36:57

    I like the efforts you have put in this, regards for all the great content.

  39. 3 周前
    2024-4-30 2:52:05

    Nice post. I learn something totally new and challenging on websites

  40. 3 周前
    2024-4-30 3:01:12

    I like the efforts you have put in this, regards for all the great content.

  41. 3 周前
    2024-4-30 5:24:52

    very informative articles or reviews at this time.

  42. 3 周前
    2024-4-30 6:42:12

    Hi there to all, for the reason that I am genuinely keen of reading this website’s post to be updated on a regular basis. It carries pleasant stuff.

  43. 3 周前
    2024-4-30 9:27:31

    I do not even understand how I ended up here, but I assumed this publish used to be great

  44. 3 周前
    2024-4-30 12:53:45

    Pretty! This has been a really wonderful post. Many thanks for providing these details.

  45. 3 周前
    2024-5-02 7:58:54

    Hi there to all, for the reason that I am genuinely keen of reading this website’s post to be updated on a regular basis. It carries pleasant stuff.

  46. 3 周前
    2024-5-02 7:59:29

    I truly appreciate your technique of writing a blog. I added it to my bookmark site list and will

  47. very informative articles or reviews at this time.

  48. 3 周前
    2024-5-03 5:43:26

    This was beautiful Admin. Thank you for your reflections.

  49. 2 周前
    2024-5-03 7:28:58

    This is my first time pay a quick visit at here and i am really happy to read everthing at one place

  50. 2 周前
    2024-5-03 7:29:51

    I just like the helpful information you provide in your articles

  51. 2 周前
    2024-5-03 8:25:53

    Hi there to all, for the reason that I am genuinely keen of reading this website’s post to be updated on a regular basis. It carries pleasant stuff.

  52. 2 周前
    2024-5-03 8:39:18

    I like the efforts you have put in this, regards for all the great content.

  53. 2 周前
    2024-5-03 8:41:02

    Good post! We will be linking to this particularly great post on our site. Keep up the great writing

  54. 2 周前
    2024-5-03 9:20:31

    I just like the helpful information you provide in your articles

  55. 2 周前
    2024-5-03 10:55:19

    I appreciate you sharing this blog post. Thanks Again. Cool.

  56. 2 周前
    2024-5-03 15:14:38

    Pretty! This has been a really wonderful post. Many thanks for providing these details.

  57. 2 周前
    2024-5-04 3:41:24

    I really like reading through a post that can make men and women think. Also, thank you for allowing me to comment!

  58. You’re so awesome! I don’t believe I have read a single thing like that before. So great to find someone with some original thoughts on this topic. Really.. thank you for starting this up. This website is something that is needed on the internet, someone with a little originality!

  59. 2 周前
    2024-5-04 6:10:24

    I am truly thankful to the owner of this web site who has shared this fantastic piece of writing at at this place.

  60. 2 周前
    2024-5-04 6:13:25

    Good post! We will be linking to this particularly great post on our site. Keep up the great writing

  61. 2 周前
    2024-5-04 7:25:44

    naturally like your web site however you need to take a look at the spelling on several of your posts. A number of them are rife with spelling problems and I find it very bothersome to tell the truth on the other hand I will surely come again again.

  62. 2 周前
    2024-5-04 8:11:02

    I truly appreciate your technique of writing a blog. I added it to my bookmark site list and will

  63. 2 周前
    2024-5-04 11:56:24

    I truly appreciate your technique of writing a blog. I added it to my bookmark site list and will

  64. 2 周前
    2024-5-04 21:38:19

    naturally like your web site however you need to take a look at the spelling on several of your posts. A number of them are rife with spelling problems and I find it very bothersome to tell the truth on the other hand I will surely come again again.

  65. Awesome! Its genuinely remarkable post, I have got much clear idea regarding from this post

  66. 7 天前
    2024-5-13 22:07:33

    I really like reading through a post that can make men and women think. Also, thank you for allowing me to comment!

  67. 7 天前
    2024-5-14 1:38:53

    naturally like your web site however you need to take a look at the spelling on several of your posts. A number of them are rife with spelling problems and I find it very bothersome to tell the truth on the other hand I will surely come again again.

  68. 7 天前
    2024-5-14 5:43:49

    This was beautiful Admin. Thank you for your reflections.

  69. 7 天前
    2024-5-14 5:43:51

    I am truly thankful to the owner of this web site who has shared this fantastic piece of writing at at this place.

  70. Very well presented. Every quote was awesome and thanks for sharing the content. Keep sharing and keep motivating others.

  71. 5 天前
    2024-5-15 16:54:22

    naturally like your web site however you need to take a look at the spelling on several of your posts. A number of them are rife with spelling problems and I find it very bothersome to tell the truth on the other hand I will surely come again again.

  72. 5 天前
    2024-5-15 16:54:47

    This was beautiful Admin. Thank you for your reflections.

  73. 5 天前
    2024-5-15 16:54:49

    I like the efforts you have put in this, regards for all the great content.

  74. 5 天前
    2024-5-15 16:59:17

    I like the efforts you have put in this, regards for all the great content.

  75. 5 天前
    2024-5-16 6:09:42

    I just like the helpful information you provide in your articles

  76. 10 小时前
    2024-5-20 8:50:56

    Great information shared.. really enjoyed reading this post thank you author for sharing this post .. appreciated

  77. 10 小时前
    2024-5-20 9:02:00

    I appreciate you sharing this blog post. Thanks Again. Cool.

  78. 9 小时前
    2024-5-20 10:40:46

    Nice post. I learn something totally new and challenging on websites

  79. 9 小时前
    2024-5-20 10:43:35

    I truly appreciate your technique of writing a blog. I added it to my bookmark site list and will

  80. 8 小时前
    2024-5-20 11:05:54

    I really like reading through a post that can make men and women think. Also, thank you for allowing me to comment!

  81. 8 小时前
    2024-5-20 11:28:00

    I am truly thankful to the owner of this web site who has shared this fantastic piece of writing at at this place.

  82. 8 小时前
    2024-5-20 11:47:21

    Hi there to all, for the reason that I am genuinely keen of reading this website’s post to be updated on a regular basis. It carries pleasant stuff.

  83. 5 小时前
    2024-5-20 14:44:15

    I just like the helpful information you provide in your articles

  84. 1 小时前
    2024-5-20 18:03:59

    I am truly thankful to the owner of this web site who has shared this fantastic piece of writing at at this place.

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇