()
| 143 | |
| 144 | |
| 145 | def is_cache_initialized() -> bool: |
| 146 | # 检查必要的属性是否存在 |
| 147 | if not hasattr(FastAPICache, "_backend") or not hasattr(FastAPICache, "_prefix"): |
| 148 | return False |
| 149 | |
| 150 | # 检查属性值是否为 None |
| 151 | if FastAPICache._backend is None or FastAPICache._prefix is None: |
| 152 | return False |
| 153 | |
| 154 | # 尝试获取后端确认 |
| 155 | try: |
| 156 | backend = FastAPICache.get_backend() |
| 157 | return backend is not None |
| 158 | except (AssertionError, AttributeError, Exception) as e: |
| 159 | SQLBotLogUtil.debug(f"缓存初始化检查失败: {str(e)}") |
| 160 | return False |