forked from j62/ctbrec
Add failFast version of getStreamInfo for faster startup
With many chaturbate models, the loading of the recording tab took a long time, because for each model the online state was loaded by the loading cache. The failFast version just returns null and makes the inital loading of recorder.getOnlineModels() much faster.
This commit is contained in:
parent
ef9566999a
commit
cbb6f3f45a
|
@ -219,7 +219,15 @@ public class Chaturbate extends AbstractSite {
|
|||
}
|
||||
|
||||
StreamInfo getStreamInfo(String modelName) throws IOException, ExecutionException {
|
||||
return streamInfoCache.get(modelName);
|
||||
return getStreamInfo(modelName, false);
|
||||
}
|
||||
|
||||
StreamInfo getStreamInfo(String modelName, boolean failFast) throws IOException, ExecutionException {
|
||||
if(failFast) {
|
||||
return streamInfoCache.getIfPresent(modelName);
|
||||
} else {
|
||||
return streamInfoCache.get(modelName);
|
||||
}
|
||||
}
|
||||
|
||||
StreamInfo loadStreamInfo(String modelName) throws HttpException, IOException, InterruptedException {
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.io.IOException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
@ -39,14 +40,16 @@ public class ChaturbateModel extends AbstractModel {
|
|||
|
||||
@Override
|
||||
public boolean isOnline(boolean ignoreCache) throws IOException, ExecutionException, InterruptedException {
|
||||
StreamInfo info;
|
||||
String roomStatus;
|
||||
if(ignoreCache) {
|
||||
info = getChaturbate().loadStreamInfo(getName());
|
||||
StreamInfo info = getChaturbate().loadStreamInfo(getName());
|
||||
roomStatus = Optional.ofNullable(info).map(i -> i.room_status).orElse("");
|
||||
LOG.trace("Model {} room status: {}", getName(), info.room_status);
|
||||
} else {
|
||||
info = getChaturbate().getStreamInfo(getName());
|
||||
StreamInfo info = getChaturbate().getStreamInfo(getName(), true);
|
||||
roomStatus = Optional.ofNullable(info).map(i -> i.room_status).orElse("");
|
||||
}
|
||||
return Objects.equals("public", info.room_status);
|
||||
return Objects.equals("public", roomStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue