Hi Ratnadeep,
Sorry for the delay in replying - I had to look at the code again to
provide sensible answers.
Q1. Is PagedQuery a singleton?
PagedQuery is not a Singleton in the traditional sense. '
self.id' is a
property:
paging.py line 507: id = property(fget=_get_query_id, doc='unique id
of this query')
this effectively makes the instance method _get_query_id() the getter
of this property. As you can see from the code, _get_query_id()
returns an existing id if it has already been generated for that
PagedQuery instance, and if not, calls _generate_query_id(). The query
id in question is defined by a hash of the pickled (serialized)
db.Query or db.GqlQuery object:
paging.py line 386: return str(hash(pickle.dumps(self._query,2)))
2 query instances of the same kind, filters, order, etc, always
serialized the same. Therefore the hash is the same. Therefore the id
is the same between separate PagedQuery instances of the same query.
Therefore, two separate PagedQuery objects of the exact same query
will find the same memcache cache.
I am not sure about GAE Java works, but in GAE Python a singleton
wouldn't work since there is no guarantee any particular instance will
receive any particular HTTP request. I hope that answers that
question.
Q2. How do we know the cursor has changed for the purposes of clearing
the cache:
Good catch. Looking at the code I don't think this implemented.
It should go in _update_cursors_with_results()
I will need to follow up with that and fix it when I have my he3-
appengine-lib development environment set up again.
I hope these answers help. Let me know if you have any more questions.
Sorry for the delay again.