     func deleteObject(aObj: O) {
         
         if aObj.uid {
+            self.cache.removeObjectForKey(aObj.uid!)
             self.deleteData(aObj.uid!)
             aObj.uid = nil;
         }


class ObjectStore<O: PersistentObject> : DataStore<ObjectStoreHeader,O.DataType> {
    
    //var objectType : Class!
    
    init(url: NSURL) {
        super.init(url: url)

        
    }
    
    /**
    func registerObject() -> UID {
        var pos = self.register()
        return self.calculateID(pos)
    }
    */
    
    
    func registerObject(aObj: O) -> UID? {
        
        var result: UID? = nil
        
        if !aObj.uid {
            // only NEW object have a nil uid
            
            var pos  = self.register()
            result = self.calculateID(pos)
            aObj.uid = result
            
            self.cache.setObject(aObj, forKey: result)
         
        }
        
        return result;
    }
    
    func createObject() -> O {
        
        var result = O()

        self.addObject(result)
        
        return result
    }
    
    func addObject(aObj: O) -> UID {
        
        var pos = self.register()
