10 | | The *entire* API of the `WebGatewayCache` should be completely untouched after this refactoring and integration tests should be added to cover all public methods. The `omero.web.webgateway_cache` setting will also need to be deprecated (it's already largely completely hidden) and the `omero.web.caches` setting documented further. |
| 7 | As we have upgraded to Django 1.3.1 in `4.4.x` and 1.6.1 in `5.x` the Django cache (https://docs.djangoproject.com/en/1.3/topics/cache/) has had significant increases in maturity. LRU backends with many features are also available such as `memcached` out of the box and `django-redis-cache` (https://github.com/sebleier/django-redis-cache). Unfortunately the lack of accessibility to complex keys makes sane cache invalidation a real problem. Redis' hierarchical keys for instance are completely inaccessible. |
| 8 | |
| 9 | Enter a Redis-only implementation. |
| 10 | |
| 11 | Such an implementation has distinct advantages: |
| 12 | * A customisable LRU (http://redis.io/topics/config ; "Configuration Redis as a cache") |
| 13 | * Hierarchical keys and more complex data types than just string (http://redis.io/topics/data-types) |
| 14 | * Is easily instrumented with command line tools such as `redis-cli` |
| 15 | * Has no external dependencies and can be easily compiled on almost all UNIX varients |
| 16 | * A simple protocol with excellent library support in all our target languages (Java, Python and C++) |
| 17 | |
| 18 | Disadvantages include: |
| 19 | * No Windows support (a restriction of both the existing system and memcached) |
| 20 | * Deployment and maintenance of another service |
| 21 | * Documentation burden |
| 22 | |
| 23 | The current top level hash (http://redis.io/topics/data-types ; "Hashes") key hierarchy is proposed: |
| 24 | |
| 25 | * `t_<client_base>_<image_id>` (thumbnails) |
| 26 | * `i_<client_base>_<image_id>` (rendered JPEG image data) |
| 27 | * `json_<client_base>` (JSON) |
| 28 | |
| 29 | The *entire* API of the `WebGatewayCache` should be completely untouched after this refactoring and integration tests should be added to cover all public methods. The `omero.web.webgateway_cache` settings will also need to be deprecated (it's already largely completely hidden) and the `omero.web.redis.*` settings documented further. |
| 30 | |
| 31 | Proposed additions to `omeroweb.settings.CUSTOM_SETTINGS_MAPPINGS`: |
| 32 | |
| 33 | * `omero.web.redis.host` (`REDIS_HOST`) default: `localhost` |
| 34 | * `omero.web.redis.port` (`REDIS_PORT`) default: `6379` |
| 35 | * `omero.web.redis.db` (`REDIS_DB`) default: `0` |
| 36 | * `omero.web.redis.timeouts` (`REDIS_DEFAULT_TIMEOUTS`) default: `{}` (no timeout; requires LRU) |
| 37 | * `omero.web.redis.thumb_hashformat` (`REDIS_THUMB_HASHFORMAT` default: `t_{client_base}_{iid}` |
| 38 | * `omero.web.redis.image_hashformat` (`REDIS_IMAGE_HASHFORMAT` default: `i_{client_base}_{iid}` |