Reputation: 463
I have come across the problem when I update one of my Entities manually in Datastore Viewer in App Engine Console, I cannot see the updates instantly from my Android application that uses that data I have updated. I know that there is Memcache from which the data is retrieved. Therefore my question is can delete the memchache for the entity I update so my application gets the new data to display? If so can someone tell me how to do it please?
P.S. I have tried using 'Flush Memcache' via the Admin Console and it did not help. I am still getting the 'old' entity
That is how I retrieve my entities. I use JDO for persisting and querying data. In my Data Accessor Object I have got this method which returns all the jobs and converts it to a JSONArray. Eventually this JSONArray is being passed to my mobile application with unfortunately 'old' data.
public JSONArray getAll() {
JSONArray array = new JSONArray();
try {
Query q = pm.newQuery(Job.class);
List<Job> resultSet = (List<Job>) q.execute();
Collections.sort(resultSet);
Iterator i =resultSet.iterator();
while (i.hasNext()){
Job j = (Job) i.next();
if(j.getDateDue().after(new Date())){
JSONObject tempjson;
tempjson = j.toJSONObject();
array.put(tempjson);
}
}
return array;
}
catch (JSONException e) {
e.printStackTrace();
}
catch(Exception e){
e.printStackTrace();
}
return null;
}
And this is my Job class. I have trimmed the code for it to show only the attributes and not to take much space.
@PersistenceCapable
public class Job implements Comparable<Job>{
@PrimaryKey
@Persistent(valueStrategy=IdGeneratorStrategy.IDENTITY)
private Key jobId;
@Persistent
private String jobTitle;
@Persistent
private String jobDescription;
@Persistent
private String address;
@Persistent
private String priority;
@Persistent
private double latitude;
@Persistent
private double longitude;
@Persistent
private String employeeId;
@Persistent
private Date dateAdded;
@Persistent
private Date dateDue;
@Persistent
private boolean completed;
It is very important to me that the app works on new updated data straight away. I appreciate any help
Upvotes: 0
Views: 426
Reputation: 24956
Since you using 'flush memcache', you side-stepped the usual problem of reaching around memcache to update entities when the software you've deployed uses memcache as a cache. The suspect now is the effect of eventual consistency when writes (puts) and subsequent queries don't use an ancestor (parent) entity. You'll need to show us some code to be sure.
Upvotes: 1