mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-11 23:20:47 +02:00
add doclines set/del metric
This commit is contained in:
@@ -41,7 +41,7 @@ module.exports = RedisManager =
|
||||
logger.error {err: error, doc_id: doc_id, docLines: docLines}, error.message
|
||||
return callback(error)
|
||||
docHash = RedisManager._computeHash(docLines)
|
||||
metrics.summary "redis.setDoc", docLines.length, {status: "set"}
|
||||
metrics.summary "redis.docLines", docLines.length, {status: "set"}
|
||||
logger.log {project_id, doc_id, version, docHash, pathname, projectHistoryId}, "putting doc in redis"
|
||||
RedisManager._serializeRanges ranges, (error, ranges) ->
|
||||
if error?
|
||||
@@ -74,6 +74,7 @@ module.exports = RedisManager =
|
||||
_callback()
|
||||
|
||||
multi = rclient.multi()
|
||||
multi.strlen keys.docLines(doc_id:doc_id)
|
||||
multi.del keys.docLines(doc_id:doc_id)
|
||||
multi.del keys.projectKey(doc_id:doc_id)
|
||||
multi.del keys.docVersion(doc_id:doc_id)
|
||||
@@ -85,8 +86,11 @@ module.exports = RedisManager =
|
||||
multi.del keys.unflushedTime(doc_id:doc_id)
|
||||
multi.del keys.lastUpdatedAt(doc_id: doc_id)
|
||||
multi.del keys.lastUpdatedBy(doc_id: doc_id)
|
||||
multi.exec (error) ->
|
||||
multi.exec (error, response) ->
|
||||
return callback(error) if error?
|
||||
length = response?[0]
|
||||
if length > 0
|
||||
metrics.summary "redis.docLines", length, {status: "del"}
|
||||
multi = rclient.multi()
|
||||
multi.srem keys.docsInProject(project_id:project_id), doc_id
|
||||
multi.del keys.projectState(project_id:project_id)
|
||||
|
||||
@@ -671,11 +671,17 @@ describe "RedisManager", ->
|
||||
|
||||
describe "removeDocFromMemory", ->
|
||||
beforeEach (done) ->
|
||||
@multi.strlen = sinon.stub()
|
||||
@multi.del = sinon.stub()
|
||||
@multi.srem = sinon.stub()
|
||||
@multi.exec.yields()
|
||||
@RedisManager.removeDocFromMemory @project_id, @doc_id, done
|
||||
|
||||
it "should check the length of the current doclines", ->
|
||||
@multi.strlen
|
||||
.calledWith("doclines:#{@doc_id}")
|
||||
.should.equal true
|
||||
|
||||
it "should delete the lines", ->
|
||||
@multi.del
|
||||
.calledWith("doclines:#{@doc_id}")
|
||||
|
||||
Reference in New Issue
Block a user