You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2020/12/23 06:53:19 UTC

[GitHub] [servicecomb-service-center] tianxiaoliang commented on a change in pull request #789: Simple implementation of mongo cache for notify event to syncer

tianxiaoliang commented on a change in pull request #789:
URL: https://github.com/apache/servicecomb-service-center/pull/789#discussion_r547683695



##########
File path: datasource/mongo/mongo.go
##########
@@ -118,3 +121,12 @@ func (ds *DataSource) createIndexes() (err error) {
 	}
 	return
 }
+
+func (ds *DataSource) initStore() {
+	if !config.GetRegistry().EnableCache {
+		log.Debug("cache is disabled")
+		return
+	}
+	sd.Store().Run()
+	<-sd.Store().Ready()

Review comment:
       为何要等着信号到来

##########
File path: datasource/mongo/sd/cache.go
##########
@@ -0,0 +1,46 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+ */
+
+package sd
+
+// Cache stores db data.
+type Cache interface {
+	CacheReader
+
+	Put(id string, v interface{})
+
+	Remove(id string)
+
+	MarkDirty()
+
+	Dirty() bool
+
+	Clear()

Review comment:
       为何将两个接口分离

##########
File path: datasource/mongo/sd/cache.go
##########
@@ -0,0 +1,46 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+ */
+
+package sd
+
+// Cache stores db data.
+type Cache interface {
+	CacheReader
+
+	Put(id string, v interface{})
+
+	Remove(id string)
+
+	MarkDirty()
+
+	Dirty() bool
+
+	Clear()

Review comment:
       不可能一个缓存写,另个一缓存读




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org