#= require modularity/data/cache # Provides fast and convenient retrieval of hash objects # by indexing them on a given key column. class modularity.IndexedCache constructor: (@key = 'id') -> @cache = new modularity.Cache add: (entry) -> @cache.add entry[@key], entry add_all: (entries) -> @add(entry) for entry in entries remove: (entry) -> @cache.remove entry[@key] remove_many: (entries) -> @cache.remove_many (entry[@key] for entry in entries) get: (key) -> @cache.get key length: => @cache.length()