调整了数据库缓存的调用,部分使用是直接使用的value,可能无法触发缓存计数
This commit is contained in:
parent
0497e9d0e2
commit
1803ef845c
@ -10,6 +10,7 @@ import com.yutou.common.databases.AbsDatabasesBean;
|
||||
import com.yutou.common.databases.SQLiteManager;
|
||||
import com.yutou.common.okhttp.HttpDownloadUtils;
|
||||
import com.yutou.common.utils.Log;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.PreparedStatement;
|
||||
@ -20,6 +21,7 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class BiliLiveDatabase extends SQLiteManager {
|
||||
@Getter
|
||||
LiveRoomConfig config;
|
||||
String fileName;
|
||||
File rootPath;
|
||||
|
@ -163,7 +163,6 @@ public class WebSocketServer {
|
||||
private class WebSocketClientTh extends WebSocketClient {
|
||||
private final LiveRoomConfig roomConfig;
|
||||
private final HeartbeatTask heartbeatTask;
|
||||
BiliLiveDatabase liveDatabase;
|
||||
private final boolean isUser;
|
||||
|
||||
public WebSocketClientTh(URI serverUri, LiveRoomConfig roomId, boolean isUser) {
|
||||
@ -171,7 +170,6 @@ public class WebSocketServer {
|
||||
Log.i("WebSocketClientTh.WebSocketClientTh : " + serverUri);
|
||||
this.isUser = isUser;
|
||||
this.roomConfig = roomId;
|
||||
liveDatabase = liveDatabasesService.getLiveDatabase(roomConfig.getRoomId());
|
||||
Brotli4jLoader.ensureAvailability();
|
||||
heartbeatTask = new HeartbeatTask();
|
||||
addHeader("User-Agent", ConfigTools.getUserAgent());
|
||||
@ -253,7 +251,7 @@ public class WebSocketServer {
|
||||
// Log.i("协议:" + useHeader + " 命令数:" + body.getBodyList().size());
|
||||
for (JSONObject json : body.getBodyList()) {
|
||||
WSData parse = WSData.parse(json);
|
||||
liveDatabase.addSource(parse);
|
||||
liveDatabasesService.getLiveDatabase(roomConfig.getRoomId()).addSource(parse);
|
||||
// Log.i("解压:" + parse);
|
||||
}
|
||||
// Log.i();
|
||||
|
@ -6,6 +6,7 @@ import com.yutou.biliapi.bean.live.LiveRoomConfig;
|
||||
import com.yutou.biliapi.bean.live.database.LiveConfigDatabaseBean;
|
||||
import com.yutou.biliapi.databases.BiliLiveConfigDatabase;
|
||||
import com.yutou.biliapi.databases.BiliLiveDatabase;
|
||||
import com.yutou.common.utils.Log;
|
||||
import lombok.Getter;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
@ -24,6 +25,7 @@ public class LiveDatabasesService {
|
||||
if (it.wasEvicted()) {
|
||||
if (it.getValue() != null) {
|
||||
((BiliLiveDatabase) it.getValue()).close();
|
||||
Log.i("缓存到期移除", ((BiliLiveDatabase) it.getValue()).getConfig().getRoomId());
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -34,7 +36,7 @@ public class LiveDatabasesService {
|
||||
configDatabase = new BiliLiveConfigDatabase();
|
||||
}
|
||||
public String getCacheInfo() {
|
||||
return "总数:"+liveDatabases.size()+","+ Arrays.toString(liveDatabases.asMap().keySet().toArray())+","+ Arrays.toString(liveDatabases.asMap().values().toArray());
|
||||
return "总数:" + liveDatabases.size() + "," + Arrays.toString(liveDatabases.asMap().keySet().toArray()) + "," + Arrays.toString(liveDatabases.asMap().values().toArray());
|
||||
}
|
||||
|
||||
public BiliLiveDatabase getLiveDatabase(String roomId) {
|
||||
|
@ -142,7 +142,6 @@ public class LiveVideoDownloadService {
|
||||
String savePath;
|
||||
File rootPath;
|
||||
LiveConfigDatabaseBean config;
|
||||
BiliLiveDatabase database;
|
||||
LiveVideoDatabaseBean videoDatabaseBean = null;
|
||||
LiveRoomInfo roomInfo;
|
||||
|
||||
@ -200,7 +199,6 @@ public class LiveVideoDownloadService {
|
||||
config.setLogin(StringUtils.hasText(bean.getRecordUid()));
|
||||
config.setRoomInfo(roomInfo);
|
||||
config.setRootPath(bean.getRecordPath());
|
||||
database = liveDatabasesService.getLiveDatabase(bean.getRoomId());
|
||||
saveLiveInfo(roomInfo);
|
||||
api.getLiveRoomPlayInfo(
|
||||
bean.getRoomId(),
|
||||
@ -356,7 +354,7 @@ public class LiveVideoDownloadService {
|
||||
}
|
||||
if (videoDatabaseBean != null) {
|
||||
videoDatabaseBean.setStopTime(new Date());
|
||||
database.addLiveInfo(videoDatabaseBean);
|
||||
liveDatabasesService.getLiveDatabase(bean.getRoomId()).addLiveInfo(videoDatabaseBean);
|
||||
}
|
||||
stopRecordDanmu();
|
||||
}
|
||||
@ -373,7 +371,7 @@ public class LiveVideoDownloadService {
|
||||
videoDatabaseBean.setPath(savePath);
|
||||
videoDatabaseBean.setRoomInfoJson(JSONObject.toJSONString(roomInfo));
|
||||
videoDatabaseBean.setStartTime(new Date());
|
||||
database.addLiveInfo(videoDatabaseBean);
|
||||
liveDatabasesService.getLiveDatabase(bean.getRoomId()).addLiveInfo(videoDatabaseBean);
|
||||
recordDanmu();
|
||||
// LiveInfoNfoTools.saveLiveInfoNfo(roomInfo, rootPath.getAbsolutePath(), new File(savePath).getName().replace(".flv", ".nfo"));
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ public abstract class SQLiteManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void close() {
|
||||
public synchronized void close() {
|
||||
try {
|
||||
conn.close();
|
||||
} catch (SQLException throwables) {
|
||||
|
Loading…
Reference in New Issue
Block a user