message: Now Service is using cache
diff: +import Cache from "caching-map"
  import { ContentStorage } from "../storage/ContentStorage";
  import { FileHash, Hashing } from "./Hashing";
  import { EntityType, Pointer, EntityId, Entity } from "./Entity";
  @@ -11,7 +12,7 @@ import { PointerManager, CommitResult } from "./pointers/PointerManager";
  export class ServiceImpl implements Service {
  - private entities: Map<EntityId, Entity> = new Map();
  + private entities: Cache = new Cache(1000)
  constructor(
  private storage: ContentStorage,
  @@ -20,6 +21,7 @@ export class ServiceImpl implements Service {
  private nameKeeper: NameKeeper,
  private analytics: ContentAnalytics,
  private ignoreValidationErrors: boolean = false) {
  + this.entities.materialize = (entityId: EntityId) => this.getEntityById(entityId)
  }
  getEntitiesByPointers(type: EntityType, pointers: Pointer[]): Promise<Entity[]> {
  @@ -32,21 +34,17 @@ export class ServiceImpl implements Service {
  getEntitiesByIds(type: EntityType, ids: EntityId[]): Promise<Entity[]> {
  return Promise.all(ids
  .filter((elem, pos, array) => array.indexOf(elem) == pos) // Removing duplicates. Quickest way to do so.
  - .map((entityId: EntityId) => this.getEntityById(entityId)))
  + .map((entityId: EntityId) => this.entities.get(entityId)))
  .then((entities:(Entity|undefined)[]) => entities.filter(entity => entity !== undefined)) as Promise<Entity[]>
  }
  private async getEntityById(id: EntityId): Promise<Entity | undefined> {
  - let entity = this.entities.get(id)
  - if (!entity) {
  - // Try to get the entity from the storage
  try {
  const buffer = await this.storage.getContent(StorageCategory.CONTENTS, id)
  - entity = EntityFactory.fromBufferWithId(buffer, id)
  - this.entities.set(id, entity)
  - } catch (error) { }
  + return EntityFactory.fromBufferWithId(buffer, id)
  + } catch (error) {
  + return undefined
  }
  - return entity
  }
  getActivePointers(type: EntityType): Promise<Pointer[]> {
  @@ -116,12 +114,7 @@ export class ServiceImpl implements Service {
  const deploymentTimestamp: Timestamp = timestampCalculator()
  // Save audit information
  - const auditInfo: AuditInfo = {
  - deployedTimestamp: deploymentTimestamp,
  - ethAddress: ethAddress,
  - signature: signature,
  - }
  - await this.storage.store(this.resolveCategory(StorageCategory.PROOFS), entity.id, Buffer.from(JSON.stringify(auditInfo)))
  + await this.storeAuditInfo(entityId, ethAddress, signature, deploymentTimestamp)
  // Add the new deployment to history
  await this.historyManager.newEntityDeployment(serverName, entity, deploymentTimestamp)
  @@ -132,6 +125,15 @@ export class ServiceImpl implements Service {
  return Promise.resolve(deploymentTimestamp)
  }
  + private storeAuditInfo(entityId: EntityId, ethAddress: EthAddress, signature: Signature, deployedTimestamp: Timestamp): Promise<void> {
  + const auditInfo: AuditInfo = {
  + deployedTimestamp,
  + ethAddress,
  + signature,
  + }
  + return this.storage.store(this.resolveCategory(StorageCategory.PROOFS), entityId, Buffer.from(JSON.stringify(auditInfo)))
  + }
  +
  private storeEntityContent(hashes: Map<FileHash, File>, alreadyStoredHashes: Map<FileHash, Boolean>, entityId: EntityId, couldCommit: boolean): Promise<any> {
  if (couldCommit) {
  // If entity was commited, then store all it's content (that isn't already stored)
  