UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'r+k2uDdqonq+p8vHhJO7/uQ4LLPVQPhROck2i6f+iD0=' 
WHERE 
  key_id = '31e4b4d8ac7157d05782e747141d962591e1071d45425f86f3767c4c6867f6d4' 
  AND (
    token = 'r+k2uDdqonq+p8vHhJO7/uQ4LLPVQPhROck2i6f+iD0=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00051