本文整理匯總了TypeScript中core/cache/deckCache.service.ICache.get方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript service.ICache.get方法的具體用法?TypeScript service.ICache.get怎麽用?TypeScript service.ICache.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類core/cache/deckCache.service.ICache
的用法示例。
在下文中一共展示了service.ICache.get方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: 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();
}
示例2: 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;
});