當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript deckCache.service.ICache類代碼示例

本文整理匯總了TypeScript中core/cache/deckCache.service.ICache的典型用法代碼示例。如果您正苦於以下問題:TypeScript service.ICache類的具體用法?TypeScript service.ICache怎麽用?TypeScript service.ICache使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了service.ICache類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

    it('should remove all items from the specified cache', () => {
      let cache: ICache = infrastructureCache.get('credentials');
      expect(cache).toBeUndefined();

      cacheInitializer.initialize().then(() => {
        cache = infrastructureCache.get('credentials');
        expect(cache).toBeDefined();
        expect(cache.keys().length).toBe(0);

        const key = 'myTestCacheKey';
        const value = 'myTestCacheValue';
        cache.put(key, value);

        expect(cache.keys().length).toBe(1);
        expect(cache.get(key)).toBe(value);

        cacheInitializer.refreshCache('credentials').then((result: any[]) => {
          expect(flatten(result)).toEqual(keys.account);
          cache = infrastructureCache.get('credentials');
          expect(cache.keys().length).toBe(0);
        });
        initialized = true;
      });
      $root.$digest();
      expect(initialized).toBeTruthy();
    });
開發者ID:jtk54,項目名稱:deck,代碼行數:26,代碼來源:cacheInitializer.service.spec.ts

示例2: getItems

 public getItems(type: any): IRecentHistoryEntry[] {
   const replacements: ICacheEntryStateMigrator[] = [
     // example: replace "application.executions" with "application.pipelines.executions"
     // {
     //   state: 'application.executions',
     //   replacement: 'application.pipelines.executions'
     // },
   ];
   const items: IRecentHistoryEntry[] = this.cache.get(type) || [];
   items.forEach(item => {
     replacements.forEach(replacement => {
       if (item.state && item.state.includes(replacement.state)) {
         item.state = item.state.replace(replacement.state, replacement.replacement);
       }
     });
   });
   return sortBy(items, 'accessTime').reverse();
 }
開發者ID:brujoand,項目名稱:deck,代碼行數:18,代碼來源:recentHistory.service.ts

示例3: removeLastItem

 public removeLastItem(type: string): void {
   const items: IRecentHistoryEntry[] = this.getItems(type);
   if (items.length) {
     items.splice(0, 1);
     this.cache.put(type, items);
   }
 }
開發者ID:brujoand,項目名稱:deck,代碼行數:7,代碼來源:recentHistory.service.ts

示例4: addExtraDataToLatest

 /**
  * Used to include additional fields needed by display formatters that might not be present in $stateParams,
  * but are resolved in a controller when the view loads
  * See instanceDetails.controller.js for an example
  * @param type
  * @param extraData
  */
 public addExtraDataToLatest(type: string, extraData: any): void {
   const items: IRecentHistoryEntry[] = this.getItems(type);
   if (items.length) {
     items[0].extraData = extraData;
     this.cache.put(type, items);
   }
 }
開發者ID:brujoand,項目名稱:deck,代碼行數:14,代碼來源:recentHistory.service.ts

示例5: removeByAppName

 /**
  * Called when deleting an application to remove its record in recent history
  * @param appName
  */
 public removeByAppName(appName: string) {
   const type = 'applications';
   const items: IRecentHistoryEntry[] = this.getItems(type);
   const remaining: IRecentHistoryEntry[] = items.filter((item) => item.params.application !== appName);
   if (remaining) {
     this.cache.put(type, remaining);
   }
 }
開發者ID:brujoand,項目名稱:deck,代碼行數:12,代碼來源:recentHistory.service.ts

示例6: removeItem

  public removeItem(type: string, id: string): void {
    const items: IRecentHistoryEntry[] = this.getItems(type),
          existing: IRecentHistoryEntry = items.find(i => i.id === id);

    if (existing) {
      items.splice(items.indexOf(existing), 1);
      this.cache.put(type, items);
    }
  }
開發者ID:brujoand,項目名稱:deck,代碼行數:9,代碼來源:recentHistory.service.ts

示例7: expect

      cacheInitializer.initialize().then(() => {
        cache = infrastructureCache.get('credentials');
        expect(cache).toBeDefined();
        expect(cache.keys().length).toBe(0);

        const key = 'myTestCacheKey';
        const value = 'myTestCacheValue';
        cache.put(key, value);

        expect(cache.keys().length).toBe(1);
        expect(cache.get(key)).toBe(value);

        cacheInitializer.refreshCache('credentials').then((result: any[]) => {
          expect(flatten(result)).toEqual(keys.account);
          cache = infrastructureCache.get('credentials');
          expect(cache.keys().length).toBe(0);
        });
        initialized = true;
      });
開發者ID:jtk54,項目名稱:deck,代碼行數:19,代碼來源:cacheInitializer.service.spec.ts

示例8: addItem

 public addItem(type: string, state: string, params: any, keyParams: string[] = []) {
   const items: IRecentHistoryEntry[] = this.getItems(type).slice(0, MAX_ITEMS),
         existing: IRecentHistoryEntry = this.getExisting(items, params, keyParams),
         entry = {
           params: params,
           state: state,
           accessTime: new Date().getTime(),
           extraData: {},
           id: UUIDGenerator.generateUuid(),
         };
   if (existing) {
     items.splice(items.indexOf(existing), 1);
   }
   if (items.length === MAX_ITEMS) {
     items.pop();
   }
   items.push(entry);
   this.cache.put(type, items);
 }
開發者ID:brujoand,項目名稱:deck,代碼行數:19,代碼來源:recentHistory.service.ts

示例9: renamePipeline

 public renamePipeline(applicationName: string, pipeline: IPipeline, currentName: string, newName: string): IPromise<void> {
   this.configViewStateCache.remove(this.buildViewStateCacheKey(applicationName, currentName));
   pipeline.name = newName;
   return this.API.one(pipeline.strategy ? 'strategies' : 'pipelines').one(pipeline.id).data(pipeline).put();
 }
開發者ID:jcwest,項目名稱:deck,代碼行數:5,代碼來源:pipelineConfig.service.ts


注:本文中的core/cache/deckCache.service.ICache類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。