UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'd/nJ+rTe8ChA7v6q/fpMvVrJpeN+LOj1SbPUC4xkvnc=' 
WHERE 
  key_id = '791b8dbf7814c9962b91393a817efb81d6581588ee302b71f1f637d05396a9b2' 
  AND (
    token = 'd/nJ+rTe8ChA7v6q/fpMvVrJpeN+LOj1SbPUC4xkvnc=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00028