UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'cD3KBtoZWaW18sCbThKLMIYuQhYX9GgCCbw+VLEH6ao=' 
WHERE 
  key_id = 'f398c3c01e1f0a9d627658d097d0c67ad444801793066385f19bede9060dc280' 
  AND (
    token = 'cD3KBtoZWaW18sCbThKLMIYuQhYX9GgCCbw+VLEH6ao=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00038