#= 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_id) -> @cache.remove entry_id remove_many: (entry_ids) -> @cache.remove_many entry_ids get: (key) -> @cache.get key length: => @cache.length()