Everytime when i start my activity i get a user object from the server by using the spicemanager.execute with params UserCacheKey and CacheTime of a week.
When i do a pull to refresh i disregard the current cached user object cache by using the spicemanager.execute without supplying the UserCacheKey and CacheTime param.
Now that i got a newUser object from the server i want to overwrite the existing user object still in cache with this new one. So what i do is i use the spicemanager.putInCache and supply the params User.class, UserCacheKey and newUserObject. What i find strange is that i can't supply a CacheTime. Anyway by now i would think the old User object is overwritten by my new one because i used the same UserCacheKey to store the object.
But when i do a call to get the user from the server(using cache) i get the old User object returned which i thought would have been overwritten by my newUser object.
Sorry it's allot of text but i don't know if i'm implementing it right.
When RoboSpice loads data from the network it is placed in the cache indexed by the cache key and object type and time stamped. At this point the expiry is meaningless. It is only used for following requests when the data is already in the cache.
What I would recommend using is execute(..., DurationInMillis.ONE_WEEK, ...)
for a normal load. This means that if data is found in the cache it'll check if it's less than a week old to be valid.
Then when manually refreshing use execute(..., DurationInMillis.ALWAYS_EXPIRED, ...)
so that the cache is skipped and data is loaded from the network. The loaded data is still stored in the cache, so the next 'normal' request can retrieve it.