Reputation: 927
I'm using memcache to implement performance gains when reading variables from the datastore. But as it turns out, memcache.get() seems slow.
Here's the code:
def get_settings():
settings = memcache.get('ds-settings')
I call get_settings() inside a model _from_pb
to run some checks everytime there is a read from the datastore, and have measured that 85/90% of the time it takes ~7ms to run, and the other 10%, it takes ~70ms to run.
When running this 100, 1k or 10k times inside a loop, it becomes a serious problem.
Any suggestions on how to make reading memcache faster?
Upvotes: 1
Views: 210
Reputation: 2618
why would you run this in a loop? if you want to multiple keys, batch them by calling memcache.get_multi.
Upvotes: 1