更新任务存储、权限与货源查询流程
Build Backend JAR / build (push) Has been cancelled

This commit is contained in:
supernijia
2026-08-22 21:23:01 +08:00
parent 7a7f1dfa21
commit 159d52194c
32 changed files with 1239 additions and 69 deletions
@@ -181,6 +181,13 @@ public class ZiniaoMemoryStoreService {
return deleted;
}
@Transactional
public int deleteAllByType(String cacheType) {
String normalizedType = normalizeRequired(cacheType, "cacheType 不能为空");
return ziniaoMemoryStoreMapper.delete(new LambdaQueryWrapper<ZiniaoMemoryStoreEntity>()
.eq(ZiniaoMemoryStoreEntity::getCacheType, normalizedType));
}
@Transactional
public int deleteExpired(int limit) {
int safeLimit = Math.max(limit, 1);
@@ -105,6 +105,19 @@ public class ZiniaoTransientCacheService {
log.trace("[ziniao-transient] delete type={}", normalizedType);
}
public int deleteByType(String cacheType) {
String normalizedType = normalizeRequired(cacheType, "cacheType 不能为空");
String prefix = normalizedType + SEP;
int deleted = 0;
for (String key : map.keySet()) {
if (key.startsWith(prefix) && map.remove(key) != null) {
deleted++;
}
}
log.trace("[ziniao-transient] delete by type={} count={}", normalizedType, deleted);
return deleted;
}
@Scheduled(fixedDelayString = "${aiimage.ziniao.transient-cache-cleanup-delay-ms:60000}")
void cleanupExpiredEntriesScheduled() {
cleanupExpiredEntries(LocalDateTime.now());
@@ -44,6 +44,11 @@ public class ZiniaoShopIndexService {
private static final String CACHE_TYPE_SHOP_INDEX_SCOPE_SNAPSHOT = "SHOP_INDEX_SCOPE_SNAPSHOT";
private static final String CACHE_TYPE_SHOP_INDEX_REFRESH_CURSOR = "SHOP_INDEX_REFRESH_CURSOR";
private static final String CACHE_TYPE_COMPANY_ID = "COMPANY_ID";
private static final String CACHE_TYPE_STAFF_LIST = "STAFF_LIST";
private static final String CACHE_TYPE_USER_STORES = "USER_STORES";
private static final String CACHE_TYPE_INVALID_USER_STORES = "INVALID_USER_STORES";
private static final String CACHE_TYPE_SHOP_MATCH = "SHOP_MATCH";
/** 有 shopId 时唯一键,避免同一店铺因不同员工/哈希产生多行。 */
private static final String SHOP_ENTRY_KEY_SHOP_PREFIX = "s:";
/** 无 shopId(冲突占位等)时仍按规范化店名存一行。 */
@@ -414,8 +419,18 @@ public class ZiniaoShopIndexService {
}
public void invalidateIndex() {
ziniaoTransientCacheService.delete(CACHE_TYPE_SHOP_INDEX_REFRESH_CURSOR, "global");
log.info("[ziniao-index] cursor invalidated (transient only; shop rows unchanged)");
int persistentDeleted = ziniaoMemoryStoreService.deleteAllByType(
ZiniaoMemoryStoreService.CACHE_TYPE_SHOP_INDEX_ENTRY);
int transientDeleted = 0;
transientDeleted += ziniaoTransientCacheService.deleteByType(CACHE_TYPE_SHOP_INDEX_SCOPE_SNAPSHOT);
transientDeleted += ziniaoTransientCacheService.deleteByType(CACHE_TYPE_SHOP_INDEX_REFRESH_CURSOR);
transientDeleted += ziniaoTransientCacheService.deleteByType(CACHE_TYPE_COMPANY_ID);
transientDeleted += ziniaoTransientCacheService.deleteByType(CACHE_TYPE_STAFF_LIST);
transientDeleted += ziniaoTransientCacheService.deleteByType(CACHE_TYPE_USER_STORES);
transientDeleted += ziniaoTransientCacheService.deleteByType(CACHE_TYPE_INVALID_USER_STORES);
transientDeleted += ziniaoTransientCacheService.deleteByType(CACHE_TYPE_SHOP_MATCH);
log.info("[ziniao-index] invalidated persistentRows={} transientEntries={} next refresh starts from offset 0",
persistentDeleted, transientDeleted);
}
private void markIpWhitelistAllowedSafely(ZiniaoApiKeyProvider.ApiKeyAccount account) {