性能优化:N+1查询改批量、串行远程调用并发化、紫鸟索引巡检批量回写
This commit is contained in:
+15
@@ -9,6 +9,7 @@ import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* P2-12:图片缩略图缓存 mapper。提供 LRU 命中刷新、按 url_hash 直读字节两个轻量入口,
|
||||
@@ -23,6 +24,20 @@ public interface TaskImageCacheMapper extends BaseMapper<TaskImageCacheEntity> {
|
||||
@Update("UPDATE biz_task_image_cache SET last_used_at = NOW(3) WHERE url_hash = #{urlHash}")
|
||||
int touchLastUsed(@Param("urlHash") String urlHash);
|
||||
|
||||
/**
|
||||
* 批量命中检查:仅取 url_hash 列(避免把 image_bytes BLOB 拉回 JVM)。
|
||||
*/
|
||||
@Select("<script>SELECT url_hash FROM biz_task_image_cache WHERE url_hash IN " +
|
||||
"<foreach collection='urlHashes' item='hash' open='(' separator=',' close=')'>#{hash}</foreach></script>")
|
||||
List<String> selectUrlHashes(@Param("urlHashes") List<String> urlHashes);
|
||||
|
||||
/**
|
||||
* 批量 bumping last_used_at。
|
||||
*/
|
||||
@Update("<script>UPDATE biz_task_image_cache SET last_used_at = NOW(3) WHERE url_hash IN " +
|
||||
"<foreach collection='urlHashes' item='hash' open='(' separator=',' close=')'>#{hash}</foreach></script>")
|
||||
int touchLastUsedBatch(@Param("urlHashes") List<String> urlHashes);
|
||||
|
||||
/**
|
||||
* 按 url_hash 直读缩略图字节,命中时返回 BLOB;未命中返回 null。
|
||||
* 选择只 select image_bytes 一列,避免把整行 entity(含 url 字符串)拉回 JVM。
|
||||
|
||||
Reference in New Issue
Block a user