import { ICache } from './ICache';

export class InMemoryCache implements ICache {
	private cache = {};

	public set(key: string, value: any): any {
		this.cache[key] = value;
		return value !== null && typeof value === 'object' ? Object.assign({}, value) : value;
	}

	public get(key: string): any {
		const value = this.cache[key];
		if (!value) {
			return null;
		}
		return typeof value === 'object' ? Object.assign({}, value) : value;
	}

	public getBatch(keys: string[]): any[] {
		return keys.map((key: string) => this.get(key));
	}

	public remove(key: string): void {
		delete this.cache[key];
	}

	public reset(): void {
		this.cache = {};
	}
}

import { ICache } from './ICache';

export class InMemoryCache implements ICache {
	private cache = {};

	public set(key: string, value: any): void {
		this.cache[key] = value;
	}

	public get(key: string): any {
		return this.cache[key];
	}

	public getBatch(keys: string[]): any[] {
		return keys.map((key: string) => {
			return this.cache[key];
		});
	}

	public remove(key: string): void {
		delete this.cache[key];
	}

	public reset(): void {
		this.cache = {};
	}
}

--- 
+++ 
@@ -3,18 +3,21 @@
 export class InMemoryCache implements ICache {
 	private cache = {};
 
-	public set(key: string, value: any): void {
+	public set(key: string, value: any): any {
 		this.cache[key] = value;
+		return value !== null && typeof value === 'object' ? Object.assign({}, value) : value;
 	}
 
 	public get(key: string): any {
-		return this.cache[key];
+		const value = this.cache[key];
+		if (!value) {
+			return null;
+		}
+		return typeof value === 'object' ? Object.assign({}, value) : value;
 	}
 
 	public getBatch(keys: string[]): any[] {
-		return keys.map((key: string) => {
-			return this.cache[key];
-		});
+		return keys.map((key: string) => this.get(key));
 	}
 
 	public remove(key: string): void {
Update in memory cache to return cloned objects
