Thank you very much for the code.
Yes, I reported the issue with search and permalinks here:
https://ww.wp.xz.cn/support/topic/need-to-clear-pods-cache-often/
But I have found it hard to know how to track down the issue. Once the caches have been cleared, the problem doesn’t occur again until a week or so later. So it’s not something that is easily reproducible.
Thank you very much for your helpful reply, Jory. I will investigate further!