diff --git a/src/lib/KVStore.hx b/src/lib/KVStore.hx index ab210f8..107f3fd 100644 --- a/src/lib/KVStore.hx +++ b/src/lib/KVStore.hx @@ -10,7 +10,7 @@ import haxe.ds.StringMap; **/ class KVStore { private var kvStore: StringMap = new StringMap(); - private final namespace:String; + public final namespace:String; public function new(namespace: String) { this.namespace = namespace; @@ -21,6 +21,11 @@ class KVStore { FS.delete(nsFile); } + public static function getStoreForClass(?pos:haxe.PosInfos) { + var className = pos.className; + return new KVStore(className); + } + private static function getNamespaceFile(namespace: String): String { return '/var/ns/$namespace'; } @@ -50,8 +55,8 @@ class KVStore { this.kvStore.set(key,value); } - public inline function get(key: String): Null { - return this.kvStore.get(key); + public inline function get(key: String,?orElse:T = null): Null { + return this.kvStore.get(key) ?? orElse; } public inline function exists(key: String): Bool {