Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
937 views
in Technique[技术] by (71.8m points)

node.js - How to use Windows Azure Table Storage Timestamp or Etag field

I am developing a node.js application on Windows Azure Websites (IISNode) and have installed the Azure SDK module for node.js my question is how to use the etag or timestamp field in table storage.

Is it a matter of "me" doing something e.g:

if (entities[0].Timestamp == newEntity.Timestamp)
    // commit this update because we are dealing with the latest copy of this entity
else
    // oops! one of the entities is newer than the other, better not save it

Or do I need to listen for a error returned by the tableService.updateEntity( ... for an error returned or something ?

Any help or advice appreciated

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The ETag is used for optimistic concurrency during updates. The ETag is set automatically when you retrieve an entity and is uploaded automatically when you update that queried entity. The update would fail if the entity has in the meantime been updated by another thread. The updateEntity method has an optional parameter, checkEtag, that can be used to modify this behavior by allowing you to specigy that the update should succeed regardless of whether or not another thread has updated the record - thereby overriding the optimistic concurrency.

The Windows Azure Storage Service REST API is the definitive interface to Windows Azure Storage, and htis is the documentation to go to when you want to understand the API capabilities of the service. The documention describing ETag, in general, is here.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

Just Browsing Browsing

[1] 怎么让ant的ant-message组件生成的元素在

2.1m questions

2.1m answers

60 comments

57.0k users

...