| 212 | } |
| 213 | |
| 214 | PyObject *ActivePyModules::cacheable_get_python(std::string_view what, const bool get_mutable) |
| 215 | { |
| 216 | const bool use_cache = |
| 217 | !get_mutable && |
| 218 | api_cache.is_enabled() && |
| 219 | api_cache.is_cacheable(what); |
| 220 | if (use_cache) { |
| 221 | PyObject* cached = api_cache.get(what); |
| 222 | if (cached) { |
| 223 | dout(20) << ": api cache hit for " << what << " hit/miss " |
| 224 | << api_cache.get_hits() << "/" << api_cache.get_misses() |
| 225 | << dendl; |
| 226 | return cached; |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | PyObject *obj = get_python(what, get_mutable); |
| 231 | if (use_cache && obj) { |
| 232 | api_cache.insert(what, obj); |
| 233 | } |
| 234 | return obj; |
| 235 | } |
| 236 | |
| 237 | PyObject *ActivePyModules::get_python(std::string_view what, const bool get_mutable) |
| 238 | { |
no test coverage detected