reject duplicate requestes

client(android or web)

add globalId or trackId

function requestServer(callback:Callback) {
  //去重,防止多次请求
  if(null != lastGlobalId && lastGlobalId === app.globalData.globalId) {
    return
  }
  lastGlobalId = app.globalData.globalId

reject by redis (every client must by diffrent)


const filterKeyExTime = 30s

async function requestUserUnionId(trackId, loginCode) {
    const filterKey = trackId
    let requesting = await api.redisGetString(filterKey);
    if(requesting) {
        api.logger(TAG, "requestUserUnionId-reject")
        return
    }
    
await api.redisSetString(filterKey, true, filterKeyExTime);

indexes by mongo or mysql

mongo4.6 : https://www.mongodb.com/docs/manual/indexes/

GUI

Mongo-Sh


db.products.createIndex(
  { item: 1, quantity: -1 } ,
  { name: "query for inventory" }
)

mysql8.x: https://dev.mysql.com/doc/refman/8.0/en/mysql-indexes.html

mysql5.x:

Primary Key