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