UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'KQTf6W4MclX0lKCbI3lxFPToiC6sRxqL1DXowl5mkrU=' 
WHERE 
  key_id = '58faba7902514bf323fae2882c36c341946df8b941169d954b2ea859dd37df1f' 
  AND (
    token = 'KQTf6W4MclX0lKCbI3lxFPToiC6sRxqL1DXowl5mkrU=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00046