diff --git a/package.json b/package.json index 14ad43b..d371b6a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cosmos-server", - "version": "0.12.0-unstable43", + "version": "0.12.0-unstable44", "description": "", "main": "test-server.js", "bugs": { diff --git a/src/utils/db.go b/src/utils/db.go index 9d51ad7..2620611 100644 --- a/src/utils/db.go +++ b/src/utils/db.go @@ -143,10 +143,11 @@ func flushAllBuffers() { func BufferedDBWrite(collectionName string, object map[string]interface{}) { bufferLock.Lock() writeBuffer[collectionName] = append(writeBuffer[collectionName], object) + bufferLock.Unlock() + if len(writeBuffer[collectionName]) >= bufferCapacity { flushBuffer(collectionName) } - bufferLock.Unlock() } func WriteToDatabase(collection *mongo.Collection, objects []map[string]interface{}) error {