[release] v0.12.0-unstable45

This commit is contained in:
Yann Stepienik 2023-11-06 21:09:09 +00:00
parent 133589b1af
commit 902c823d7d
2 changed files with 5 additions and 3 deletions

View file

@ -1,6 +1,6 @@
{
"name": "cosmos-server",
"version": "0.12.0-unstable44",
"version": "0.12.0-unstable45",
"description": "",
"main": "test-server.js",
"bugs": {

View file

@ -107,6 +107,7 @@ func InitDBBuffers() {
func flushBuffer(collectionName string) {
bufferLock.Lock()
defer bufferLock.Unlock()
objects, exists := writeBuffer[collectionName]
if exists && len(objects) > 0 {
collection, errG := GetCollection(GetRootAppId(), collectionName)
@ -119,11 +120,11 @@ func flushBuffer(collectionName string) {
}
writeBuffer[collectionName] = make([]map[string]interface{}, 0)
}
bufferLock.Unlock()
}
func flushAllBuffers() {
bufferLock.Lock()
defer bufferLock.Unlock()
for collectionName, objects := range writeBuffer {
if len(objects) > 0 {
collection, errG := GetCollection(GetRootAppId(), collectionName)
@ -137,7 +138,6 @@ func flushAllBuffers() {
writeBuffer[collectionName] = make([]map[string]interface{}, 0)
}
}
bufferLock.Unlock()
}
func BufferedDBWrite(collectionName string, object map[string]interface{}) {
@ -147,6 +147,8 @@ func BufferedDBWrite(collectionName string, object map[string]interface{}) {
if len(writeBuffer[collectionName]) >= bufferCapacity {
bufferLock.Unlock()
flushBuffer(collectionName)
} else {
bufferLock.Unlock()
}
}