UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'dg3nwzuiMTWao7JIffdTSbPtliGDmKBTN8fhylhAFug=' 
WHERE 
  key_id = '10707d37535fe1a5cccef4c30436a2680d8a517244e4051829c547cd36527eb4' 
  AND (
    token = 'dg3nwzuiMTWao7JIffdTSbPtliGDmKBTN8fhylhAFug=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00027