Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix: remove billing cache when add or delete app or member (#25885)
zyssyz1237dadb33003b3
diff --git a/api/services/account_service.py b/api/services/account_service.pyindex 8362e415c1b..0e699d16da4 100644--- a/api/services/account_service.py+++ b/api/services/account_service.py@@ -1041,6 +1041,8 @@ class TenantService:db.session.add(ta)db.session.commit()+ if dify_config.BILLING_ENABLED:+ BillingService.clean_billing_info_cache(tenant.id)return ta@staticmethod@@ -1199,6 +1201,9 @@ class TenantService:db.session.delete(ta)db.session.commit()+ if dify_config.BILLING_ENABLED:+ BillingService.clean_billing_info_cache(tenant.id)+@staticmethoddef update_member_role(tenant: Tenant, member: Account, new_role: str, operator: Account):"""Update member role"""diff --git a/api/services/app_service.py b/api/services/app_service.pyindex ab2b38ec019..d524adbf3e1 100644--- a/api/services/app_service.py+++ b/api/services/app_service.py@@ -20,6 +20,7 @@ from libs.login import current_userfrom models.account import Accountfrom models.model import App, AppMode, AppModelConfig, Sitefrom models.tools import ApiToolProvider+from services.billing_service import BillingServicefrom services.enterprise.enterprise_service import EnterpriseServicefrom services.feature_service import FeatureServicefrom services.tag_service import TagService@@ -162,6 +163,9 @@ class AppService:# update web app setting as privateEnterpriseService.WebAppAuth.update_app_access_mode(app.id, "private")+ if dify_config.BILLING_ENABLED:+ BillingService.clean_billing_info_cache(app.tenant_id)+return appdef get_app(self, app: App) -> App:@@ -337,6 +341,9 @@ class AppService:if FeatureService.get_system_features().webapp_auth.enabled:EnterpriseService.WebAppAuth.cleanup_webapp(app.id)+ if dify_config.BILLING_ENABLED:+ BillingService.clean_billing_info_cache(app.tenant_id)+# Trigger asynchronous deletion of app and related dataremove_app_and_related_data_task.delay(tenant_id=app.tenant_id, app_id=app.id)diff --git a/api/services/billing_service.py b/api/services/billing_service.pyindex a364862a88d..9d6c5b4b311 100644--- a/api/services/billing_service.py+++ b/api/services/billing_service.py@@ -5,6 +5,7 @@ import httpxfrom tenacity import retry, retry_if_exception_type, stop_before_delay, wait_fixedfrom extensions.ext_database import db+from extensions.ext_redis import redis_clientfrom libs.helper import RateLimiterfrom models.account import Account, TenantAccountJoin, TenantAccountRole@@ -173,3 +174,7 @@ class BillingService:res = cls._send_request("POST", "/compliance/download", json=json)cls.compliance_download_rate_limiter.increment_rate_limit(limiter_key)return res++ @classmethod+ def clean_billing_info_cache(cls, tenant_id: str):+ redis_client.delete(f"tenant:{tenant_id}:billing_info")