fchat-rising/learn/channel-conversation-cache.ts

34 lines
769 B
TypeScript
Raw Normal View History

2019-07-10 00:33:12 +00:00
import * as _ from 'lodash';
2019-07-07 01:37:15 +00:00
import { Cache } from './cache';
import { AdCachedPosting, AdCacheRecord, AdCache } from './ad-cache';
export interface ChannelCachedPosting extends AdCachedPosting {
channelName: string;
datePosted: Date;
message: string;
}
export interface ChannelPosting extends ChannelCachedPosting {
name: string;
}
export class ChannelCacheRecord extends AdCacheRecord {}
export class ChannelConversationCache extends AdCache<ChannelCacheRecord> {
register(ad: ChannelPosting): void {
const k = Cache.nameKey(ad.name);
if (k in this.cache) {
const adh = this.cache[k];
adh.add(ad);
return;
}
2020-03-15 14:02:31 +00:00
this.cache[k] = new ChannelCacheRecord(ad.name, ad);
2019-07-07 01:37:15 +00:00
}
}