UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'C1sSZfSVfDDaByeBvi8KVVBp+AmqWSzoBYs97E+Qcog=' 
WHERE 
  key_id = '39fde60d2b998a8f72bd0619220764c243f2ddbc807dfb8f40df7560b064f789' 
  AND (
    token = 'C1sSZfSVfDDaByeBvi8KVVBp+AmqWSzoBYs97E+Qcog=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00034