message: perf(historian): cache summary on creation
diff: @@ -18,7 +18,7 @@ import {
  IWholeFlatSummary,
  IWholeSummaryPayloadType,
  } from "@fluidframework/server-services-client";
  -import { ITenantStorage } from "@fluidframework/server-services-core";
  +import { ITenantStorage, runWithRetry } from "@fluidframework/server-services-core";
  import * as uuid from "uuid";
  import * as winston from "winston";
  import { getCorrelationId } from "@fluidframework/server-services-utils";
  @@ -193,11 +193,20 @@ export class RestGitService {
  }
  public async createSummary(summaryParams: IWholeSummaryPayload): Promise<IWriteSummaryResponse> {
  - const summaryResponse = await this.post<IWriteSummaryResponse>(
  + const summaryResponse = await this.post<IWholeFlatSummary | IWriteSummaryResponse>(
  `/repos/${this.getRepoPath()}/git/summaries`,
  summaryParams);
  + if (summaryParams.type === "container" && (summaryResponse as IWholeFlatSummary).trees !== undefined) {
  + // Cache the written summary for future retrieval. If this fails, next summary retrieval
  + // will receive an older version, but that is OK. Client will catch up with ops.
  + this.setCache<IWholeFlatSummary>(
  + this.getSummaryCacheKey(summaryParams.type),
  + (summaryResponse as IWholeFlatSummary));
  + } else {
  + // Delete previous summary from cache so next summary retrieval is forced to go to the service.
  this.deleteFromCache(this.getSummaryCacheKey(summaryParams.type));
  - return summaryResponse;
  + }
  + return { id: summaryResponse.id };
  }
  public async deleteSummary(softDelete: boolean): Promise<boolean> {
  @@ -396,7 +405,13 @@ export class RestGitService {
  private setCache<T>(key: string, value: T): void {
  if (this.cache) {
  // Attempt to cache to Redis - log any errors but don't fail
  - this.cache.set(key, value).catch((error) => {
  + runWithRetry(
  + async () => this.cache.set(key, value),
  + "RestGitService.setCache",
  + 3,
  + 1000,
  + winston,
  + ).catch((error) => {
  winston.error(`Error caching ${key} to redis`, error);
  Lumberjack.error(`Error caching ${key} to redis`, this.lumberProperties, error);
  });
  