forked from j62/ctbrec
Remove resolution cache
Resolution caching is done globally in ThumbCell
This commit is contained in:
parent
b99e88d2c8
commit
d4dadf9fea
|
@ -189,17 +189,6 @@ public class Chaturbate extends AbstractSite {
|
|||
}
|
||||
});
|
||||
|
||||
LoadingCache<String, int[]> streamResolutionCache = CacheBuilder.newBuilder()
|
||||
.initialCapacity(10_000)
|
||||
.maximumSize(10_000)
|
||||
.expireAfterWrite(5, TimeUnit.MINUTES)
|
||||
.build(new CacheLoader<String, int[]> () {
|
||||
@Override
|
||||
public int[] load(String model) throws Exception {
|
||||
return loadResolution(model);
|
||||
}
|
||||
});
|
||||
|
||||
public void sendTip(String name, int tokens) throws IOException {
|
||||
if (!Objects.equals(System.getenv("CTBREC_DEV"), "1")) {
|
||||
RequestBody body = new FormBody.Builder()
|
||||
|
@ -264,11 +253,9 @@ public class Chaturbate extends AbstractSite {
|
|||
}
|
||||
}
|
||||
|
||||
public int[] getResolution(String modelName) throws ExecutionException {
|
||||
return streamResolutionCache.get(modelName);
|
||||
}
|
||||
public int[] getResolution(String modelName) throws ExecutionException, IOException, ParseException, PlaylistException, InterruptedException {
|
||||
throttleRequests();
|
||||
|
||||
private int[] loadResolution(String modelName) throws IOException, ParseException, PlaylistException, ExecutionException, InterruptedException {
|
||||
int[] res = new int[2];
|
||||
StreamInfo streamInfo = getStreamInfo(modelName);
|
||||
if(!streamInfo.url.startsWith("http")) {
|
||||
|
@ -303,7 +290,6 @@ public class Chaturbate extends AbstractSite {
|
|||
throw ex;
|
||||
}
|
||||
|
||||
streamResolutionCache.put(modelName, res);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import okhttp3.Response;
|
|||
public class ChaturbateModel extends AbstractModel {
|
||||
|
||||
private static final transient Logger LOG = LoggerFactory.getLogger(ChaturbateModel.class);
|
||||
private int[] resolution = new int[2];
|
||||
|
||||
/**
|
||||
* This constructor exists only for deserialization. Please don't call it directly
|
||||
|
@ -52,16 +53,16 @@ public class ChaturbateModel extends AbstractModel {
|
|||
|
||||
@Override
|
||||
public int[] getStreamResolution(boolean failFast) throws ExecutionException {
|
||||
int[] resolution = getChaturbate().streamResolutionCache.getIfPresent(getName());
|
||||
if(resolution != null) {
|
||||
return getChaturbate().getResolution(getName());
|
||||
} else {
|
||||
if(failFast) {
|
||||
return new int[2];
|
||||
} else {
|
||||
return getChaturbate().getResolution(getName());
|
||||
}
|
||||
if(failFast) {
|
||||
return resolution;
|
||||
}
|
||||
|
||||
try {
|
||||
resolution = getChaturbate().getResolution(getName());
|
||||
} catch(Exception e) {
|
||||
throw new ExecutionException(e);
|
||||
}
|
||||
return resolution;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -71,7 +72,6 @@ public class ChaturbateModel extends AbstractModel {
|
|||
@Override
|
||||
public void invalidateCacheEntries() {
|
||||
getChaturbate().streamInfoCache.invalidate(getName());
|
||||
getChaturbate().streamResolutionCache.invalidate(getName());
|
||||
}
|
||||
|
||||
public String getOnlineState() throws IOException, ExecutionException {
|
||||
|
|
Loading…
Reference in New Issue