Disable Volley cache management

前端 未结 3 2097
生来不讨喜
生来不讨喜 2020-12-05 13:50

Is there a way I could disable the Volley cache management? My app is using Google Volley library to manage the transport layer, but I have my own cache manager implementati

3条回答
  •  攒了一身酷
    2020-12-05 13:55

    If you use any of the default Request classes implemented in volley(e.g. StringRequest, JsonRequest, etc.), then call setShouldCache(false) right before adding the request object to the volley RequestQueue:

    request.setShouldCache(false);
    myQueue.add(request);
    

    If you have your own implementation of the Request class, then you can call setShouldCache(false) in the constructor of your class.

    This solution disables caching for each requests individually. If you want to disable caching globally from the volley library, you can permanently set the mShouldCache variable to false in the Request class.

提交回复
热议问题