本文整理汇总了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;
});