gpt4 book ai didi

android - 从Android中的AWSAppSyncClient删除/清除缓存策略

转载 作者:行者123 更新时间:2023-12-02 13:34:53 24 4
gpt4 key购买 nike

我正在尝试从AWSAppSyncClient删除/清除缓存机制。

现在的问题是我早早得到了存储或请求的值(它正在缓存该值并返回该值)

我想要的是,它应该从api返回值。(不应缓存该值)。

我已经试过了

AWSAppSyncClient.builder()
.context(syncPort.androidContext())
.awsConfiguration(AWSConfiguration(syncPort.androidContext()))
.build()
.clearCaches(ClearCacheOptions.builder().clearSubscriptions().build())

查询代码:
override fun getMedication(date: String): Single<SampleAdministration> {
return Single.create<SampleAdministration> { emitter ->
client.query(
GetSampleQuery.builder().date(date).build()
).enqueue(object : GraphQLCall.Callback<GetSampleQuery.Data>() {
override fun onFailure(e: ApolloException) {
emitter.onError(e)
}

override fun onResponse(response: Response<GetSampleQuery.Data>) {
val data = response.data()?.sample
val sampleAdministration = object : SampleAdministration {
override var date: String? =
data?.date()
}
emitter.onSuccess(sampleAdministration)
}
})
}

}

最佳答案

我已经从AWSAppSyncClient.builder()删除clearCaches

并在查询中添加了responseFetcher

 override fun getMedication(date: String): Single<SampleAdministration> {
return Single.create<SampleAdministration> { emitter ->
client.query(
GetSampleQuery.builder().date(date).build()
).responseFetcher(AppSyncResponseFetchers.NETWORK_ONLY).enqueue(object : GraphQLCall.Callback<GetSampleQuery.Data>() {
override fun onFailure(e: ApolloException) {
emitter.onError(e)
}override fun onResponse(response: Response<GetSampleQuery.Data>) {
val data = response.data()?.sample
val sampleAdministration = object : SampleAdministration {
override var date: String? =
data?.date()
}
emitter.onSuccess(sampleAdministration)
}
})
}

关于android - 从Android中的AWSAppSyncClient删除/清除缓存策略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58620898/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com