rabbah commented on a change in pull request #2832: Do not cache invalidate
when adding a DB attachment
URL:
https://github.com/apache/incubator-openwhisk/pull/2832#discussion_r153964961
##########
File path:
common/scala/src/main/scala/whisk/core/database/DocumentFactory.scala
##########
@@ -178,12 +178,19 @@ trait DocumentFactory[W] extends
MultipleReadersSingleWriterCache[W, DocInfo] {
implicit val logger = db.logging
implicit val ec = db.executionContext
- val key = CacheKey(doc.id.asDocInfo)
- // invalidate the key because attachments update the revision;
- // do not cache the new attachment (controller does not need it)
- cacheInvalidate(key, {
- val src = StreamConverters.fromInputStream(() => bytes)
- db.attach(doc, attachmentName, contentType, src)
+ val rev = doc match {
+ case w: DocumentRevisionProvider => w.rev
+ }
+ val key = CacheKey(doc)
+ val docInfo = DocInfo(DocId(key.mainId), rev)
+ val src = StreamConverters.fromInputStream(() => bytes)
+
+ cacheUpdate(doc, key, db.attach(docInfo, attachmentName, contentType,
src) map { newDocInfo =>
+ doc match {
+ // if doc has a revision id, update it with new version
+ case w: DocumentRevisionProvider => w.revision[W](newDocInfo.rev)
+ }
+ docInfo
Review comment:
shouldn't this return new doc info?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services