-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
为何我设置了也不走缓存呢,都是走的服务器? #40
Comments
添加下面的代码试试
|
这个放在什么地方呢?我把你的工程弄到本地,用来访问我的接口也不会缓存 这个跟服务器有关系吗? |
|
没有添加任何字段,我直接修改的demo里的Rx2 test |
你看看LOGCAT TAG = retrofitcache 提示是否是从缓存加载的数据 |
Mobile:
Android OS: 8.0
NetWork: WIFI
URL:
LIB Version:
OkHttpClient httpClient = new OkHttpClient.Builder()
.cache(cache)
// .cookieJar(new CookieManger(mContext.getApplicationContext()))
.connectTimeout(15, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.writeTimeout(30, TimeUnit.SECONDS)
.protocols(Arrays.asList(Protocol.HTTP_2, Protocol.HTTP_1_1))
.addInterceptor(MyInterceptor)
.addInterceptor(new CacheForceInterceptorNoNet())
.addNetworkInterceptor(new CacheInterceptorOnNet())
.build();
mRetrofit = new Retrofit.Builder()
.baseUrl(mApiServer)
.client(httpClient)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.build();
RetrofitCache.getInstance().init(mContext.getApplicationContext()).setDefaultTimeUnit(TimeUnit.SECONDS).setDefaultTime(30);
RetrofitCache.getInstance().addRetrofit(mRetrofit);
mApiService = mRetrofit.create(IApiService.class);
@Cache(time = 10,timeUnit = TimeUnit.MINUTES)
@get("v1/robot")
Observable<ResultVO> getRobotInfo();
这是我的设置,不管我怎么设置时间,都不走缓存是什么原因,哪儿写错了吗?
The text was updated successfully, but these errors were encountered: