[release] v0.12.0-unstable45
This commit is contained in:
parent
133589b1af
commit
902c823d7d
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "cosmos-server",
|
||||
"version": "0.12.0-unstable44",
|
||||
"version": "0.12.0-unstable45",
|
||||
"description": "",
|
||||
"main": "test-server.js",
|
||||
"bugs": {
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue