Files
docs/mongo-ops/mcp/modules/mongo_ops.cache.in_memory.json
Vishesh 'ironeagle' Bangotra fced40af59 feat(standards): codify codegen, ship generic Tier-B infra, add get_app_template + prompts; fix docs:// regressions
P0: fix doc:// -> docs:// across standards src/server/registry and regenerate stale mongo-ops bundle. P1: build recipe + spec-first routing now document the openapi-first codegen fast path (models/routes with --inject-request/--package). P4: CRUD template documents the model-vs-document id rule (BaseDocument owns id). P5: authless guidance (omit security keys). P6: template gains generic infra (http_cache, keyed SSE bus, KV port+in-memory+Redis), interfaces/openapi.py + .dockerignore + generic build test registered as components, and a get_app_template tool; genericity matrix marks LLM pool + human-in-loop as reference-app patterns. P7: intake/build/start_app/trial prompts. P8: template ships tests/integration/test_openapi_app_builds.py. Rebuilt standards + openapi-first bundles and re-collected.
2026-10-13 03:26:51 +05:30

204 lines
10 KiB
JSON

{
"module": "mongo_ops.cache.in_memory",
"content": {
"path": "mongo_ops.cache.in_memory",
"docstring": "# Summary\n\nIn-memory cache backend with TTL-based eviction and encode/decode helpers.",
"objects": {
"CacheBackend": {
"name": "CacheBackend",
"kind": "class",
"path": "mongo_ops.cache.in_memory.CacheBackend",
"signature": null,
"docstring": "Abstract interface for cache backends.\n\nImplementations store byte-encoded values keyed by string, track usage\nstatistics, and manage their own lifecycle. The in-memory and Redis\nbackends both implement this contract.",
"members": {
"get": {
"name": "get",
"kind": "function",
"path": "mongo_ops.cache.in_memory.CacheBackend.get",
"signature": "get(key: str)",
"docstring": "Fetch a value from the cache.\n\nArgs:\n key (str):\n The cache key.\n\nReturns:\n Optional[bytes]: The cached bytes, or None on a miss."
},
"set": {
"name": "set",
"kind": "function",
"path": "mongo_ops.cache.in_memory.CacheBackend.set",
"signature": "set(key: str, value: bytes, ttl: int | None = None)",
"docstring": "Store a value in the cache.\n\nArgs:\n key (str):\n The cache key.\n value (bytes):\n The byte-encoded value to store.\n ttl (Optional[int]):\n Time-to-live in seconds. When None, the backend default\n applies."
},
"delete": {
"name": "delete",
"kind": "function",
"path": "mongo_ops.cache.in_memory.CacheBackend.delete",
"signature": "delete(key: str)",
"docstring": "Remove a key from the cache.\n\nArgs:\n key (str):\n The cache key."
},
"exists": {
"name": "exists",
"kind": "function",
"path": "mongo_ops.cache.in_memory.CacheBackend.exists",
"signature": "exists(key: str)",
"docstring": "Check whether a key is present.\n\nArgs:\n key (str):\n The cache key.\n\nReturns:\n bool: True if the key exists, False otherwise."
},
"clear_pattern": {
"name": "clear_pattern",
"kind": "function",
"path": "mongo_ops.cache.in_memory.CacheBackend.clear_pattern",
"signature": "clear_pattern(pattern: str)",
"docstring": "Remove all keys matching a glob pattern.\n\nArgs:\n pattern (str):\n Glob-style pattern; a trailing `*` matches prefixes."
},
"get_stats": {
"name": "get_stats",
"kind": "function",
"path": "mongo_ops.cache.in_memory.CacheBackend.get_stats",
"signature": "get_stats()",
"docstring": "Return a snapshot of cache statistics.\n\nReturns:\n CacheStats: A copy of the current stats counters."
},
"initialize": {
"name": "initialize",
"kind": "function",
"path": "mongo_ops.cache.in_memory.CacheBackend.initialize",
"signature": "initialize()",
"docstring": "Start background resources owned by the backend.\n\nShould be called once during application startup, after the\nrepositories are connected."
},
"shutdown": {
"name": "shutdown",
"kind": "function",
"path": "mongo_ops.cache.in_memory.CacheBackend.shutdown",
"signature": "shutdown()",
"docstring": "Stop and release background resources.\n\nShould be called once during application shutdown."
}
}
},
"CacheStats": {
"name": "CacheStats",
"kind": "class",
"path": "mongo_ops.cache.in_memory.CacheStats",
"signature": "CacheStats(hits: int = 0, misses: int = 0, sets: int = 0, deletes: int = 0, current_size: int = 0, max_size: int = 0)",
"docstring": "Snapshot of cache usage and activity counters.\n\nAttributes:\n hits (int):\n Number of get() calls that found a value.\n misses (int):\n Number of get() calls that returned None.\n sets (int):\n Number of values written to the cache.\n deletes (int):\n Number of keys removed.\n current_size (int):\n Number of entries currently held.\n max_size (int):\n Maximum number of entries the cache allows (0 = unbounded).",
"members": {
"hits": {
"name": "hits",
"kind": "attribute",
"path": "mongo_ops.cache.in_memory.CacheStats.hits",
"signature": null,
"docstring": null
},
"misses": {
"name": "misses",
"kind": "attribute",
"path": "mongo_ops.cache.in_memory.CacheStats.misses",
"signature": null,
"docstring": null
},
"sets": {
"name": "sets",
"kind": "attribute",
"path": "mongo_ops.cache.in_memory.CacheStats.sets",
"signature": null,
"docstring": null
},
"deletes": {
"name": "deletes",
"kind": "attribute",
"path": "mongo_ops.cache.in_memory.CacheStats.deletes",
"signature": null,
"docstring": null
},
"current_size": {
"name": "current_size",
"kind": "attribute",
"path": "mongo_ops.cache.in_memory.CacheStats.current_size",
"signature": null,
"docstring": null
},
"max_size": {
"name": "max_size",
"kind": "attribute",
"path": "mongo_ops.cache.in_memory.CacheStats.max_size",
"signature": null,
"docstring": null
}
}
},
"InMemoryCacheBackend": {
"name": "InMemoryCacheBackend",
"kind": "class",
"path": "mongo_ops.cache.in_memory.InMemoryCacheBackend",
"signature": "InMemoryCacheBackend(max_entries: int = 10000, default_ttl: int = 300, cleanup_interval: int = 60)",
"docstring": "Cache backend backed by an in-memory dict with TTL expiry.\n\nEntries are stored in an OrderedDict for LRU-compatible eviction and a\nmin-heap of expiry timestamps drives periodic removal of stale entries.\n\nNotes:\n **Thread safety:**\n\n All operations take an asyncio lock; the backend is safe for\n concurrent use within a single event loop.",
"members": {
"initialize": {
"name": "initialize",
"kind": "function",
"path": "mongo_ops.cache.in_memory.InMemoryCacheBackend.initialize",
"signature": "initialize() -> None",
"docstring": "Start the periodic expired-entry cleanup task."
},
"shutdown": {
"name": "shutdown",
"kind": "function",
"path": "mongo_ops.cache.in_memory.InMemoryCacheBackend.shutdown",
"signature": "shutdown() -> None",
"docstring": "Cancel and await the cleanup task."
},
"get": {
"name": "get",
"kind": "function",
"path": "mongo_ops.cache.in_memory.InMemoryCacheBackend.get",
"signature": "get(key: str) -> bytes | None",
"docstring": "Fetch a value from the cache.\n\nArgs:\n key (str):\n The cache key.\n\nReturns:\n Optional[bytes]: The cached bytes, or None on a miss."
},
"set": {
"name": "set",
"kind": "function",
"path": "mongo_ops.cache.in_memory.InMemoryCacheBackend.set",
"signature": "set(key: str, value: bytes, ttl: int | None = None) -> None",
"docstring": "Store a value in the cache.\n\nArgs:\n key (str):\n The cache key.\n value (bytes):\n The byte-encoded value to store.\n ttl (Optional[int]):\n Time-to-live in seconds; defaults to the backend default."
},
"delete": {
"name": "delete",
"kind": "function",
"path": "mongo_ops.cache.in_memory.InMemoryCacheBackend.delete",
"signature": "delete(key: str) -> None",
"docstring": "Remove a key from the cache.\n\nArgs:\n key (str):\n The cache key."
},
"exists": {
"name": "exists",
"kind": "function",
"path": "mongo_ops.cache.in_memory.InMemoryCacheBackend.exists",
"signature": "exists(key: str) -> bool",
"docstring": "Check whether a key is present.\n\nArgs:\n key (str):\n The cache key.\n\nReturns:\n bool: True if the key exists, False otherwise."
},
"clear_pattern": {
"name": "clear_pattern",
"kind": "function",
"path": "mongo_ops.cache.in_memory.InMemoryCacheBackend.clear_pattern",
"signature": "clear_pattern(pattern: str) -> None",
"docstring": "Remove all keys matching a glob pattern.\n\nArgs:\n pattern (str):\n Glob-style pattern; a trailing `*` matches prefixes."
},
"get_stats": {
"name": "get_stats",
"kind": "function",
"path": "mongo_ops.cache.in_memory.InMemoryCacheBackend.get_stats",
"signature": "get_stats() -> CacheStats",
"docstring": "Return a snapshot of cache statistics.\n\nReturns:\n CacheStats: A copy of the current stats counters."
}
}
},
"encode_value": {
"name": "encode_value",
"kind": "function",
"path": "mongo_ops.cache.in_memory.encode_value",
"signature": "encode_value(value: dict) -> bytes",
"docstring": "Encode a dict into cache-ready bytes.\n\nNon-serializable values (e.g., ObjectId) are coerced with str().\n\nArgs:\n value (dict):\n The dictionary to encode.\n\nReturns:\n bytes: UTF-8 JSON bytes."
},
"decode_value": {
"name": "decode_value",
"kind": "function",
"path": "mongo_ops.cache.in_memory.decode_value",
"signature": "decode_value(data: bytes) -> dict",
"docstring": "Decode cache bytes back into a dict.\n\nArgs:\n data (bytes):\n UTF-8 JSON bytes produced by encode_value().\n\nReturns:\n dict: The decoded dictionary."
}
}
}
}