prismicio-community / java-kit

Community maintained development kit for Prismic and the Java language
https://prismic.io
15 stars 38 forks source link

Problem with cache implementations #31

Closed jonhill closed 10 years ago

jonhill commented 10 years ago

Version: 1.0-M9 I've tried to use the NoCache and found that because the get returns null then the Api class tries to parse a null:

line 68: ApiData apiData = ApiData.parse(json);

Also when using the BuiltInCache, when an item expires, the HTTP Request never fires. I can see that the item is put in a Pending state, but line 17 of HttpClient checks the cache again and retrieves the stale item.

In the Cache implementation we have: JsonNode json = f.execute(); // Checks the cache again! this.set(key, ttl, json);

srenault commented 10 years ago

Hi @jonhill, I expect this commit https://github.com/prismicio/java-kit/commit/a936fcc774cca431e1e377656197b402be082b0c fix all the issues you expose above. Thanks for reporting this.

jonhill commented 10 years ago

You just beat me to it! I'd just been testing this option:

if (cachedResult != null && !cache.isPending(url)) { return cachedResult; }

jonhill commented 10 years ago

In my application I've been using version 1.0.M9 which has the pagination in class Documents, which I am using. The master branch does not have this yet. Will this be merged in soon do you know?

srenault commented 10 years ago

The Documents class has been renamed to "Response". You should be able to access it !