feat(backend): Simplify caching to just store routes (#11140)

### Problem
Limits caching to just the main marketplace routes

### Changes 🏗️

- **Simplified store cache implementation** in
`backend/server/v2/store/cache.py`
  - Streamlined caching logic for better maintainability
  - Reduced complexity while maintaining performance
  
- **Added cache invalidation on store updates**
  - Implemented cache clearing when new agents are added to the store
- Added invalidation logic in admin store routes
(`admin_store_routes.py`)
  - Ensures all pods reflect the latest store state after modifications

- **Updated store database operations** in
`backend/server/v2/store/db.py`
  - Modified to work with the new cache structure
  
- **Added cache deletion tests** (`test_cache_delete.py`)
  - Validates cache invalidation works correctly
  - Ensures cache consistency across operations

### Checklist 📋

#### For code changes:
- [x] I have clearly listed my changes in the PR description
- [x] I have made a test plan
- [x] I have tested my changes according to the test plan:
  - [x] Verify store listings are cached correctly
  - [x] Upload a new agent to the store and confirm cache is invalidated
This commit is contained in:
Swifty
2025-10-13 09:25:59 +02:00
committed by GitHub
parent 20acd8b51d
commit e32c509ccc
6 changed files with 159 additions and 286 deletions

View File

@@ -2553,7 +2553,7 @@
"get": {
"tags": ["v2", "store", "public"],
"summary": "List store agents",
"description": "Get a paginated list of agents from the store with optional filtering and sorting.\nResults are cached for 15 minutes.\n\nArgs:\n featured (bool, optional): Filter to only show featured agents. Defaults to False.\n creator (str | None, optional): Filter agents by creator username. Defaults to None.\n sorted_by (str | None, optional): Sort agents by \"runs\" or \"rating\". Defaults to None.\n search_query (str | None, optional): Search agents by name, subheading and description. Defaults to None.\n category (str | None, optional): Filter agents by category. Defaults to None.\n page (int, optional): Page number for pagination. Defaults to 1.\n page_size (int, optional): Number of agents per page. Defaults to 20.\n\nReturns:\n StoreAgentsResponse: Paginated list of agents matching the filters\n\nRaises:\n HTTPException: If page or page_size are less than 1\n\nUsed for:\n- Home Page Featured Agents\n- Home Page Top Agents\n- Search Results\n- Agent Details - Other Agents By Creator\n- Agent Details - Similar Agents\n- Creator Details - Agents By Creator",
"description": "Get a paginated list of agents from the store with optional filtering and sorting.\n\nArgs:\n featured (bool, optional): Filter to only show featured agents. Defaults to False.\n creator (str | None, optional): Filter agents by creator username. Defaults to None.\n sorted_by (str | None, optional): Sort agents by \"runs\" or \"rating\". Defaults to None.\n search_query (str | None, optional): Search agents by name, subheading and description. Defaults to None.\n category (str | None, optional): Filter agents by category. Defaults to None.\n page (int, optional): Page number for pagination. Defaults to 1.\n page_size (int, optional): Number of agents per page. Defaults to 20.\n\nReturns:\n StoreAgentsResponse: Paginated list of agents matching the filters\n\nRaises:\n HTTPException: If page or page_size are less than 1\n\nUsed for:\n- Home Page Featured Agents\n- Home Page Top Agents\n- Search Results\n- Agent Details - Other Agents By Creator\n- Agent Details - Similar Agents\n- Creator Details - Agents By Creator",
"operationId": "getV2List store agents",
"parameters": [
{
@@ -2639,7 +2639,7 @@
"get": {
"tags": ["v2", "store", "public"],
"summary": "Get specific agent",
"description": "This is only used on the AgentDetails Page.\nResults are cached for 15 minutes.\n\nIt returns the store listing agents details.",
"description": "This is only used on the AgentDetails Page.\n\nIt returns the store listing agents details.",
"operationId": "getV2Get specific agent",
"parameters": [
{
@@ -2679,7 +2679,7 @@
"get": {
"tags": ["v2", "store"],
"summary": "Get agent graph",
"description": "Get Agent Graph from Store Listing Version ID.\nResults are cached for 1 hour.",
"description": "Get Agent Graph from Store Listing Version ID.",
"operationId": "getV2Get agent graph",
"security": [{ "HTTPBearerJWT": [] }],
"parameters": [
@@ -2713,7 +2713,7 @@
"get": {
"tags": ["v2", "store"],
"summary": "Get agent by version",
"description": "Get Store Agent Details from Store Listing Version ID.\nResults are cached for 1 hour.",
"description": "Get Store Agent Details from Store Listing Version ID.",
"operationId": "getV2Get agent by version",
"security": [{ "HTTPBearerJWT": [] }],
"parameters": [
@@ -2803,7 +2803,7 @@
"get": {
"tags": ["v2", "store", "public"],
"summary": "List store creators",
"description": "This is needed for:\n- Home Page Featured Creators\n- Search Results Page\n\nResults are cached for 1 hour.\n\n---\n\nTo support this functionality we need:\n- featured: bool - to limit the list to just featured agents\n- search_query: str - vector search based on the creators profile description.\n- sorted_by: [agent_rating, agent_runs] -",
"description": "This is needed for:\n- Home Page Featured Creators\n- Search Results Page\n\n---\n\nTo support this functionality we need:\n- featured: bool - to limit the list to just featured agents\n- search_query: str - vector search based on the creators profile description.\n- sorted_by: [agent_rating, agent_runs] -",
"operationId": "getV2List store creators",
"parameters": [
{
@@ -2871,7 +2871,7 @@
"get": {
"tags": ["v2", "store", "public"],
"summary": "Get creator details",
"description": "Get the details of a creator.\nResults are cached for 1 hour.\n- Creator Details Page",
"description": "Get the details of a creator.\n- Creator Details Page",
"operationId": "getV2Get creator details",
"parameters": [
{
@@ -2905,7 +2905,7 @@
"get": {
"tags": ["v2", "store", "private"],
"summary": "Get my agents",
"description": "Get user's own agents.\nResults are cached for 5 minutes per user.",
"description": "Get user's own agents.",
"operationId": "getV2Get my agents",
"security": [{ "HTTPBearerJWT": [] }],
"parameters": [
@@ -3000,7 +3000,7 @@
"get": {
"tags": ["v2", "store", "private"],
"summary": "List my submissions",
"description": "Get a paginated list of store submissions for the authenticated user.\nResults are cached for 1 hour per user.\n\nArgs:\n user_id (str): ID of the authenticated user\n page (int, optional): Page number for pagination. Defaults to 1.\n page_size (int, optional): Number of submissions per page. Defaults to 20.\n\nReturns:\n StoreListingsResponse: Paginated list of store submissions\n\nRaises:\n HTTPException: If page or page_size are less than 1",
"description": "Get a paginated list of store submissions for the authenticated user.\n\nArgs:\n user_id (str): ID of the authenticated user\n page (int, optional): Page number for pagination. Defaults to 1.\n page_size (int, optional): Number of submissions per page. Defaults to 20.\n\nReturns:\n StoreListingsResponse: Paginated list of store submissions\n\nRaises:\n HTTPException: If page or page_size are less than 1",
"operationId": "getV2List my submissions",
"security": [{ "HTTPBearerJWT": [] }],
"parameters": [