angular/angular.js — pull request #1583 by taralx (2012-11-15 23:22:35+00:00)
Title: Make Cache.put return the value

Using cache.put is slightly awkward because you can't just wrap an expression with it like you can a standard object.

Coffeescript with plain object:
cache = {}
(key) -> cache[key] ?= genValue(key)

Coffeescript with $cacheFactory cache:

cache = $cacheFactory.get('cache')
(key) -> cache.get(key) ? (r = genValue(key); cache.put(key, r); r)

With this change:

cache = $cacheFactory.get('cache')
(key) -> cache.get(key) ? cache.put(key, genValue(key))