datastore: Export query struct fields #4341
Labels
api: datastore
Issues related to the Datastore API.
priority: p2
Moderately-important priority. Fix may not be included in next release.
type: feature request
‘Nice-to-have’ improvement, new feature or different behavior or design.
Is your feature request related to a problem? Please describe.
I'm trying to use Redis to cache datastore entities and queries. The problem is that the
Query
struct does not export any of its fields (kind, ancestor, etc) so I have no way of generating a cache key from a provided query, other than using hacky reflection techniques or building a wrapper around it.Describe the solution you'd like
Export fields that could be used to generate a redis key:
Describe alternatives you've considered
Current best alternative is to build a wrapper around Query so a way to uniquely id query can be captured or to use hacky reflection (which I don't want to do since a later version of datastore may break it).
As an example:
Given a
key datastore.Key
I can generate a redis key withfmt.Sprintf("%s:%d", key.Kind, key.ID)
. With a query though... I have no way of uniquely fingerprinting it so it's hard to map a query to cached results of that query. If you don't want to expose those fields, maybe aFingerprint()
method would be fine as well.i.e. if you had a
q datastore.Query
you could callq.Fingerprint()
which returns a string that uniquely identifies it (could be as simple askind:ancestor:filters:order:projection:limit
, for exampleUser:::Last Name::100
)The text was updated successfully, but these errors were encountered: