use of io.rx_cache2.EvictDynamicKey in project 91Pop by DanteAndroid.
the class AppApiHelper method loadPigAvListByCategory.
@Override
public Observable<List<PigAv>> loadPigAvListByCategory(String category, boolean pullToRefresh) {
DynamicKey dynamicKey = new DynamicKey(category);
EvictDynamicKey evictDynamicKey = new EvictDynamicKey(pullToRefresh);
if ("index".equals(category)) {
return action(cacheProviders.cacheWithLimitTime(pigAvServiceApi.pigAvVideoList(addressHelper.getPigAvAddress()), dynamicKey, evictDynamicKey));
} else {
return action(cacheProviders.cacheWithLimitTime(pigAvServiceApi.pigAvVideoList(addressHelper.getPigAvAddress() + category + "av線上看"), dynamicKey, evictDynamicKey));
}
}
use of io.rx_cache2.EvictDynamicKey in project 91Pop by DanteAndroid.
the class AppApiHelper method loadPorn91MyFavoriteVideos.
@Override
public Observable<BaseResult<List<UnLimit91PornItem>>> loadPorn91MyFavoriteVideos(String userName, int page, boolean cleanCache) {
Observable<String> favoriteObservable = noLimit91PornServiceApi.myFavoriteVideo(page, HeaderUtils.getIndexHeader(addressHelper));
DynamicKeyGroup dynamicKeyGroup = new DynamicKeyGroup(userName, page);
EvictDynamicKey evictDynamicKey = new EvictDynamicKey(cleanCache);
return cacheProviders.getFavorite(favoriteObservable, dynamicKeyGroup, evictDynamicKey).map(new Function<Reply<String>, String>() {
@Override
public String apply(Reply<String> responseBody) throws Exception {
return responseBody.getData();
}
}).map(new Function<String, BaseResult<List<UnLimit91PornItem>>>() {
@Override
public BaseResult<List<UnLimit91PornItem>> apply(String s) throws Exception {
return Parse91PronVideo.parseMyFavorite(s);
}
});
}
use of io.rx_cache2.EvictDynamicKey in project RxCache by VictorAlbertos.
the class ProxyTranslatorTest method When_Evict_Cache_Dynamic_Key_Evict.
@Test
public void When_Evict_Cache_Dynamic_Key_Evict() throws NoSuchMethodException {
final String dynamicKey = "aDynamicKey";
Method mockMethod = io.rx_cache2.internal.ProvidersRxCache.class.getDeclaredMethod("getMocksDynamicKeyEvictPage", Observable.class, DynamicKey.class, EvictDynamicKey.class);
Object[] dataMethodEvict = { Observable.just(new Object[] {}), new DynamicKey(dynamicKey), new EvictDynamicKey(true) };
ConfigProvider configProvider = proxyTranslatorUT.processMethod(mockMethod, dataMethodEvict);
EvictDynamicKey evictDynamicKey = (EvictDynamicKey) configProvider.evictProvider();
assertThat(configProvider.getDynamicKey(), is(dynamicKey));
assertThat(evictDynamicKey.evict(), is(true));
Object[] dataMethodNoEvict = { Observable.just(new Object[] {}), new DynamicKey(dynamicKey), new EvictDynamicKey(false) };
configProvider = proxyTranslatorUT.processMethod(mockMethod, dataMethodNoEvict);
evictDynamicKey = (EvictDynamicKey) configProvider.evictProvider();
assertThat(configProvider.getDynamicKey(), is(dynamicKey));
assertThat(evictDynamicKey.evict(), is(false));
}
use of io.rx_cache2.EvictDynamicKey in project RxCache by VictorAlbertos.
the class ProxyTranslatorTest method When_Use_Evict_Dynamic_Key_Providing_Dynamic_Key_Not_Throw_Exception.
@Test
public void When_Use_Evict_Dynamic_Key_Providing_Dynamic_Key_Not_Throw_Exception() throws NoSuchMethodException {
Method mockMethod = io.rx_cache2.internal.ProvidersRxCache.class.getDeclaredMethod("getMockEvictDynamicKeyProvidingDynamicKey", Observable.class, DynamicKey.class, EvictDynamicKey.class);
Object[] data = { Observable.just(new Object[] {}), new DynamicKey("1"), new EvictDynamicKey(true) };
proxyTranslatorUT.processMethod(mockMethod, data);
}
use of io.rx_cache2.EvictDynamicKey in project 91Pop by DanteAndroid.
the class AppApiHelper method loadPorn91VideoUrl.
@Override
public Observable<VideoResult> loadPorn91VideoUrl(String viewKey) {
String ip = addressHelper.getRandomIPAddress();
Observable<String> stringObservable = noLimit91PornServiceApi.getVideoPlayPage(viewKey, ip, HeaderUtils.getIndexHeader(addressHelper));
return cacheProviders.getVideoPlayPage(stringObservable, new DynamicKey(viewKey), new EvictDynamicKey(false)).map(new Function<Reply<String>, String>() {
@Override
public String apply(Reply<String> responseBodyReply) throws Exception {
switch(responseBodyReply.getSource()) {
case CLOUD:
Logger.t(TAG).d("数据来自:网络");
break;
case MEMORY:
Logger.t(TAG).d("数据来自:内存");
break;
case PERSISTENCE:
Logger.t(TAG).d("数据来自:磁盘缓存");
break;
default:
break;
}
return responseBodyReply.getData();
}
}).map(new Function<String, VideoResult>() {
@Override
public VideoResult apply(String s) throws Exception {
return Parse91PronVideo.parseVideoPlayUrl(s);
}
});
}
Aggregations