UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'KG+FiJtp+I6cpolcZ02q6Nmzw0+2dGkS9x8wrxRIUZs=' 
WHERE 
  key_id = '166adb7b159498b6e3db05e23906ca624ce0b933c53dcaca25a2d0a9646cb429' 
  AND (
    token = 'KG+FiJtp+I6cpolcZ02q6Nmzw0+2dGkS9x8wrxRIUZs=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00036