| 
									
										
										
										
											2020-02-05 17:11:30 +00:00
										 |  |  | import * as plugins from './levelcache.plugins'; | 
					
						
							| 
									
										
										
										
											2020-02-14 17:28:13 +00:00
										 |  |  | import { CacheDiskManager } from './levelcache.classes.cache.diskmanager'; | 
					
						
							|  |  |  | import { CacheMemoryManager } from './levelcache.classes.cache.memorymanager'; | 
					
						
							|  |  |  | import { CacheS3Manager } from './levelcache.classes.cache.s3manager'; | 
					
						
							| 
									
										
										
										
											2020-02-14 18:10:10 +00:00
										 |  |  | import { CacheEntry } from './levelcache.classes.cacheentry'; | 
					
						
							| 
									
										
										
										
											2020-02-05 17:11:30 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * a leveled cache for storing things for a short time | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | export class LevelCache { | 
					
						
							| 
									
										
										
										
											2020-02-06 16:55:55 +00:00
										 |  |  |   public cacheMap = new plugins.lik.Objectmap(); | 
					
						
							| 
									
										
										
										
											2020-02-14 17:28:13 +00:00
										 |  |  |   public cacheDiskManager = new CacheDiskManager(); | 
					
						
							|  |  |  |   public cacheMemoryManager = new CacheMemoryManager(); | 
					
						
							|  |  |  |   public cacheS3Manager = new CacheS3Manager(); | 
					
						
							| 
									
										
										
										
											2020-02-05 17:11:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-14 18:10:10 +00:00
										 |  |  |   private processKey (keyArg: string) { | 
					
						
							|  |  |  |     if (!keyArg) { | 
					
						
							|  |  |  |       return plugins.smartunique.shortId(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-06 16:55:55 +00:00
										 |  |  |   // Blobs
 | 
					
						
							|  |  |  |   /** | 
					
						
							|  |  |  |    * store a Blob | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2020-02-14 18:10:10 +00:00
										 |  |  |   public async storeBlobByKey (keyArg: string, blob: Buffer) { | 
					
						
							|  |  |  |     keyArg = this.processKey(keyArg); | 
					
						
							|  |  |  |     return keyArg; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2020-02-05 17:11:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-06 16:55:55 +00:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * retrieve a blob | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2020-02-14 18:10:10 +00:00
										 |  |  |   public async retrieveBlob (keyArg: string): CacheEntry { | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2020-02-06 16:55:55 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-14 17:28:13 +00:00
										 |  |  |   // Cache Entries
 | 
					
						
							| 
									
										
										
										
											2020-02-06 16:55:55 +00:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * store a Cache Entries | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2020-02-14 18:10:10 +00:00
										 |  |  |   public async storeCacheEntry(cacheEntryArg: CacheEntry): string { | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2020-02-14 17:28:13 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   /** | 
					
						
							|  |  |  |    * retrieve cache entry | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2020-02-14 18:10:10 +00:00
										 |  |  |   public async retrieveCacheEntry (): CacheEntry { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2020-02-05 17:11:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-14 17:28:13 +00:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * cleans the cache | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2020-02-14 18:10:10 +00:00
										 |  |  |   public clean() { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   }; | 
					
						
							| 
									
										
										
										
											2020-02-05 17:11:30 +00:00
										 |  |  | } |