stormpath/stormpath-sdk-python — pull request #84 by denibertovic (2014-09-10 12:25:09+00:00)
Title: Caching fixes

Added MAX_ENTRIES for Memory Store instances. We switched to and OrderedDict because we need to be able to evict from the head of the cache.

I didn't add any time based eviction as it is already present via the Cache.ttl and Cache.tti values (not just for the Memory store but for the RedisStore as well). These are set to 300 seconds by default but are customizable by the user via the store_opts parameter.

Max entries can be customized as well via the store_opts dict like so

cache_opts = {'store': MemoryStore, 'store_opts': {'max_entries': 2}}
client = Client(api_key_file_location=...., cache_options=cache_opts)

This parameter is only passed along to the MemoryStore instance. Other instances like the RedisStore will ignore it.

Let me know what you think.